﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:ed="http://schemas.microsoft.com/expression/2010/drawing" xmlns:params="clr-namespace:Elysium.Parameters" xmlns:primitives="clr-namespace:Elysium.Controls.Primitives" xmlns:controls="clr-namespace:Elysium.Controls" xmlns:converters="clr-namespace:Elysium.Converters">
  <ResourceDictionary.MergedDictionaries>
    <ResourceDictionary Source="/Elysium;component/Themes/Brushes.xaml" />
    <ResourceDictionary Source="/Elysium;component/Themes/LightBrushes.xaml" />
  </ResourceDictionary.MergedDictionaries>
  <converters:DoubleToGridLengthConverter x:Key="DoubleToGridLengthConverter" />
  <converters:DoubleToThicknessConverter x:Key="DoubleToThicknessConverter" />
  <converters:GridLengthToDoubleConverter x:Key="GridLengthToDoubleConverter" />
  <converters:ThicknessToDoubleConverter x:Key="ThicknessToDoubleConverter" />
  <converters:PercentToAngleConverter x:Key="PercentToAngleConverter" />
  <converters:AngleToCoordinateConverter x:Key="AngleToCoordinateConverter" />
  <converters:NumberPositiveToNegativeConverter x:Key="NumberPositiveToNegativeConverter" />
  <converters:ThicknessPositiveToNegativeConverter x:Key="ThicknessPositiveToNegativeConverter" />
  <converters:ThicknessConverter x:Key="ThicknessConverter" />
  <converters:IsGreaterThanConverter x:Key="IsGreaterThanConverter" />
  <Style x:Key="FocusVisualStyle">
    <Setter Property="Control.Template">
      <Setter.Value>
        <ControlTemplate>
          <Rectangle Margin="{TemplateBinding params:General.DefaultPadding}" Stroke="{StaticResource ForegroundBrush}" StrokeThickness="{TemplateBinding params:General.DefaultThicknessValue}" StrokeDashArray="2 1" RenderOptions.EdgeMode="Aliased" />
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>
  <GeometryGroup x:Key="AdvancedIcon">
    <EllipseGeometry Center="3,3" RadiusX="2.5" RadiusY="2.5" />
    <EllipseGeometry Center="12,3" RadiusX="2.5" RadiusY="2.5" />
    <EllipseGeometry Center="21,3" RadiusX="2.5" RadiusY="2.5" />
  </GeometryGroup>
  <GeometryGroup x:Key="MinimizeIcon" FillRule="EvenOdd">
    <RectangleGeometry Rect="0,0,10,10" />
    <RectangleGeometry Rect="0,0,10,7" />
  </GeometryGroup>
  <GeometryGroup x:Key="MaximizeIcon">
    <LineGeometry StartPoint="0,0.5" EndPoint="10,0.5" />
    <LineGeometry StartPoint="0,1.5" EndPoint="10,1.5" />
    <LineGeometry StartPoint="0,2.5" EndPoint="10,2.5" />
    <LineGeometry StartPoint="0.5,3" EndPoint="0.5,10" />
    <LineGeometry StartPoint="9.5,3" EndPoint="9.5,10" />
    <LineGeometry StartPoint="1,9.5" EndPoint="9,9.5" />
  </GeometryGroup>
  <GeometryGroup x:Key="RestoreIcon">
    <LineGeometry StartPoint="3,0.5" EndPoint="10,0.5" />
    <LineGeometry StartPoint="3,1.5" EndPoint="10,1.5" />
    <LineGeometry StartPoint="3.5,2" EndPoint="3.5,3" />
    <LineGeometry StartPoint="9.5,2" EndPoint="9.5,7" />
    <LineGeometry StartPoint="7,6.5" EndPoint="10,6.5" />
    <LineGeometry StartPoint="0,3.5" EndPoint="7,3.5" />
    <LineGeometry StartPoint="0,4.5" EndPoint="7,4.5" />
    <LineGeometry StartPoint="0.5,5" EndPoint="0.5,10" />
    <LineGeometry StartPoint="6.5,5" EndPoint="6.5,10" />
    <LineGeometry StartPoint="1,9.5" EndPoint="6,9.5" />
  </GeometryGroup>
  <GeometryGroup x:Key="CloseIcon">
    <LineGeometry StartPoint="1,0" EndPoint="10,9" />
    <LineGeometry StartPoint="0,1" EndPoint="9,10" />
    <LineGeometry StartPoint="1,1" EndPoint="9,9" />
    <LineGeometry StartPoint="9,0" EndPoint="0,9" />
    <LineGeometry StartPoint="10,1" EndPoint="1,10" />
    <LineGeometry StartPoint="9,1" EndPoint="1,9" />
  </GeometryGroup>
  <Style x:Key="ButtonsBaseStyle" TargetType="{x:Type ButtonBase}">
    <Setter Property="Background" Value="{StaticResource AccentBrush}" />
    <Setter Property="BorderBrush" Value="{StaticResource AccentBrush}" />
    <Setter Property="BorderThickness" Value="{Binding RelativeSource={RelativeSource Self}, Path=(params:General.DefaultThickness), Mode=OneWay}" />
    <Setter Property="Foreground" Value="{StaticResource ContrastBrush}" />
    <Setter Property="FontSize" Value="{Binding RelativeSource={RelativeSource Self}, Path=(params:General.ContentFontSize), Mode=OneWay}" />
    <Setter Property="FontStretch" Value="Medium" />
    <Setter Property="FontStyle" Value="Normal" />
    <Setter Property="FontWeight" Value="SemiBold" />
    <Setter Property="TextOptions.TextFormattingMode" Value="Display" />
    <Setter Property="TextOptions.TextRenderingMode" Value="ClearType" />
    <Setter Property="RenderOptions.ClearTypeHint" Value="Enabled" />
    <Setter Property="Focusable" Value="True" />
    <Setter Property="FocusVisualStyle" Value="{StaticResource FocusVisualStyle}" />
    <Setter Property="HorizontalContentAlignment" Value="Center" />
    <Setter Property="VerticalContentAlignment" Value="Center" />
    <Setter Property="Padding" Value="{Binding RelativeSource={RelativeSource Self}, Path=(params:General.BoldPadding), Mode=OneWay}" />
    <Setter Property="MinWidth" Value="70" />
    <Setter Property="SnapsToDevicePixels" Value="True" />
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type ButtonBase}">
          <Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" TextBlock.Foreground="{TemplateBinding Foreground}" TextBlock.FontFamily="{TemplateBinding FontFamily}" TextBlock.FontSize="{TemplateBinding FontSize}" TextBlock.FontStretch="{TemplateBinding FontStretch}" TextBlock.FontStyle="{TemplateBinding FontStyle}" TextBlock.FontWeight="{TemplateBinding FontWeight}" TextOptions.TextFormattingMode="{TemplateBinding TextOptions.TextFormattingMode}" TextOptions.TextRenderingMode="{TemplateBinding TextOptions.TextRenderingMode}" RenderOptions.ClearTypeHint="{TemplateBinding RenderOptions.ClearTypeHint}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">
            <ContentPresenter Margin="{TemplateBinding Padding}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" RecognizesAccessKey="True" />
          </Border>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
    <Style.Triggers>
      <DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=FontSize, Mode=OneWay, Converter={StaticResource IsGreaterThanConverter}, ConverterParameter=18}">
        <Setter Property="TextOptions.TextFormattingMode" Value="Ideal" />
      </DataTrigger>
      <Trigger Property="IsMouseOver" Value="True">
        <Setter Property="Background" Value="{StaticResource ForegroundBrush}" />
        <Setter Property="BorderBrush" Value="{StaticResource ForegroundBrush}" />
        <Setter Property="Foreground" Value="{StaticResource BackgroundBrush}" />
      </Trigger>
      <Trigger Property="IsPressed" Value="True">
        <Setter Property="Background" Value="{StaticResource LowlightBrush}" />
        <Setter Property="BorderBrush" Value="{StaticResource LowlightBrush}" />
        <Setter Property="Foreground" Value="{StaticResource BackgroundBrush}" />
      </Trigger>
      <Trigger Property="IsEnabled" Value="False">
        <Setter Property="Background" Value="{StaticResource DisabledBrush}" />
        <Setter Property="BorderBrush" Value="{StaticResource DisabledBrush}" />
        <Setter Property="Foreground" Value="{StaticResource BackgroundBrush}" />
      </Trigger>
    </Style.Triggers>
  </Style>
  <Style TargetType="{x:Type Button}" BasedOn="{StaticResource ButtonsBaseStyle}">
    <!-- Temporary removed to fix bugs 1144, 1174, 1216 -->
    <!--<Setter Property="OverridesDefaultStyle" Value="True"/>-->
    <Style.Triggers>
      <Trigger Property="IsDefault" Value="True">
        <Setter Property="FontWeight" Value="Bold" />
      </Trigger>
    </Style.Triggers>
  </Style>
  <Style TargetType="{x:Type RepeatButton}" BasedOn="{StaticResource ButtonsBaseStyle}">
    <!-- Temporary removed to fix bugs 1144, 1174, 1216 -->
    <!--<Setter Property="OverridesDefaultStyle" Value="True"/>-->
  </Style>
  <Style TargetType="{x:Type ToggleButton}" BasedOn="{StaticResource ButtonsBaseStyle}">
    <!-- Temporary removed to fix bugs 1144, 1174, 1216 -->
    <!--<Setter Property="OverridesDefaultStyle" Value="True"/>-->
    <Style.Triggers>
      <Trigger Property="IsChecked" Value="True">
        <Setter Property="Background" Value="{StaticResource LowlightBrush}" />
        <Setter Property="BorderBrush" Value="{StaticResource LowlightBrush}" />
        <Setter Property="Foreground" Value="{StaticResource BackgroundBrush}" />
      </Trigger>
    </Style.Triggers>
  </Style>
  <Style TargetType="{x:Type CheckBox}">
    <Setter Property="Background" Value="{StaticResource BackgroundBrush}" />
    <Setter Property="BorderBrush" Value="{StaticResource MiddleLightBrush}" />
    <Setter Property="BorderThickness" Value="{Binding RelativeSource={RelativeSource Self}, Path=(params:General.DefaultThickness), Mode=OneWay}" />
    <Setter Property="Foreground" Value="{StaticResource ForegroundBrush}" />
    <Setter Property="FontSize" Value="{Binding RelativeSource={RelativeSource Self}, Path=(params:General.ContentFontSize), Mode=OneWay}" />
    <Setter Property="FontStretch" Value="Medium" />
    <Setter Property="FontStyle" Value="Normal" />
    <Setter Property="FontWeight" Value="Normal" />
    <Setter Property="FocusVisualStyle" Value="{StaticResource FocusVisualStyle}" />
    <Setter Property="HorizontalContentAlignment" Value="Left" />
    <Setter Property="VerticalContentAlignment" Value="Top" />
    <Setter Property="Padding" Value="{Binding RelativeSource={RelativeSource Self}, Path=(params:General.BoldPadding), Mode=OneWay, Converter={StaticResource DoubleToThicknessConverter}, ConverterParameter=Left}" />
    <!-- Temporary removed to fix bugs 1144, 1174, 1216 -->
    <!--<Setter Property="OverridesDefaultStyle" Value="True"/>-->
    <Setter Property="SnapsToDevicePixels" Value="True" />
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type CheckBox}">
          <BulletDecorator Background="{StaticResource TransparentBrush}" TextBlock.Foreground="{TemplateBinding Foreground}" TextBlock.FontFamily="{TemplateBinding FontFamily}" TextBlock.FontSize="{TemplateBinding FontSize}" TextBlock.FontWeight="{TemplateBinding FontWeight}" FlowDirection="{TemplateBinding FlowDirection}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">
            <BulletDecorator.Bullet>
              <Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Width="{TemplateBinding params:Bullet.DecoratorSize}" Height="{TemplateBinding params:Bullet.DecoratorSize}">
                <Grid>
                  <Path x:Name="CheckBullet" Stroke="{StaticResource AccentBrush}" StrokeThickness="{TemplateBinding params:General.BoldThicknessValue}" Stretch="Fill" Visibility="Collapsed" Width="{TemplateBinding params:CheckBox.CheckSize}" Height="{TemplateBinding params:CheckBox.CheckSize}">
                    <Path.Data>
                      <GeometryGroup>
                        <LineGeometry StartPoint="0,3" EndPoint="4,8" />
                        <LineGeometry StartPoint="4,8" EndPoint="8,0" />
                      </GeometryGroup>
                    </Path.Data>
                  </Path>
                  <Path x:Name="IndeterminateBullet" Fill="{StaticResource AccentBrush}" StrokeThickness="0" Stretch="Fill" Visibility="Collapsed" Margin="2" Width="{TemplateBinding params:Bullet.Size}" Height="{TemplateBinding params:Bullet.Size}">
                    <Path.Data>
                      <GeometryGroup>
                        <RectangleGeometry Rect="0,0,1,1" />
                      </GeometryGroup>
                    </Path.Data>
                  </Path>
                </Grid>
              </Border>
            </BulletDecorator.Bullet>
            <Border Margin="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(params:General.BoldPaddingValue), Mode=OneWay, Converter={StaticResource DoubleToThicknessConverter}, ConverterParameter=Left}">
              <ContentPresenter Margin="{TemplateBinding Padding}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" RecognizesAccessKey="True" />
            </Border>
          </BulletDecorator>
          <ControlTemplate.Triggers>
            <Trigger Property="IsChecked" Value="True">
              <Setter TargetName="CheckBullet" Property="Visibility" Value="Visible" />
            </Trigger>
            <MultiTrigger>
              <MultiTrigger.Conditions>
                <Condition Property="IsThreeState" Value="True" />
                <Condition Property="IsChecked" Value="{x:Null}" />
              </MultiTrigger.Conditions>
              <MultiTrigger.Setters>
                <Setter TargetName="IndeterminateBullet" Property="Visibility" Value="Visible" />
              </MultiTrigger.Setters>
            </MultiTrigger>
            <Trigger Property="IsEnabled" Value="False">
              <Setter TargetName="CheckBullet" Property="Path.Stroke" Value="{StaticResource DisabledBrush}" />
              <Setter TargetName="IndeterminateBullet" Property="Path.Fill" Value="{StaticResource DisabledBrush}" />
            </Trigger>
          </ControlTemplate.Triggers>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
    <Style.Triggers>
      <Trigger Property="IsMouseOver" Value="True">
        <Setter Property="Background" Value="{StaticResource HighlightBrush}" />
        <Setter Property="BorderBrush" Value="{StaticResource MiddleLightBrush}" />
      </Trigger>
      <Trigger Property="IsPressed" Value="True">
        <Setter Property="Background" Value="{StaticResource HighlightBrush}" />
        <Setter Property="BorderBrush" Value="{StaticResource LowlightBrush}" />
      </Trigger>
      <Trigger Property="IsEnabled" Value="False">
        <Setter Property="Background" Value="{StaticResource BackgroundBrush}" />
        <Setter Property="BorderBrush" Value="{StaticResource DisabledBrush}" />
        <Setter Property="Foreground" Value="{StaticResource DisabledBrush}" />
      </Trigger>
    </Style.Triggers>
  </Style>
  <Style TargetType="{x:Type RadioButton}">
    <Setter Property="Background" Value="{StaticResource BackgroundBrush}" />
    <Setter Property="BorderBrush" Value="{StaticResource MiddleLightBrush}" />
    <Setter Property="BorderThickness" Value="{Binding RelativeSource={RelativeSource Self}, Path=(params:General.DefaultThickness), Mode=OneWay}" />
    <Setter Property="Foreground" Value="{StaticResource ForegroundBrush}" />
    <Setter Property="FontSize" Value="{Binding RelativeSource={RelativeSource Self}, Path=(params:General.ContentFontSize), Mode=OneWay}" />
    <Setter Property="FontStretch" Value="Medium" />
    <Setter Property="FontStyle" Value="Normal" />
    <Setter Property="FontWeight" Value="Normal" />
    <Setter Property="FocusVisualStyle" Value="{StaticResource FocusVisualStyle}" />
    <Setter Property="HorizontalContentAlignment" Value="Left" />
    <Setter Property="VerticalContentAlignment" Value="Top" />
    <Setter Property="Padding" Value="{Binding RelativeSource={RelativeSource Self}, Path=(params:General.BoldPadding), Mode=OneWay, Converter={StaticResource DoubleToThicknessConverter}, ConverterParameter=Left}" />
    <!-- Temporary removed to fix bugs 1144, 1174, 1216 -->
    <!--<Setter Property="OverridesDefaultStyle" Value="True"/>-->
    <Setter Property="SnapsToDevicePixels" Value="True" />
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type RadioButton}">
          <BulletDecorator Background="{StaticResource TransparentBrush}" TextBlock.Foreground="{TemplateBinding Foreground}" TextBlock.FontFamily="{TemplateBinding FontFamily}" TextBlock.FontSize="{TemplateBinding FontSize}" TextBlock.FontWeight="{TemplateBinding FontWeight}" FlowDirection="{TemplateBinding FlowDirection}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">
            <BulletDecorator.Bullet>
              <Grid Width="{TemplateBinding params:Bullet.DecoratorSize}" Height="{TemplateBinding params:Bullet.DecoratorSize}">
                <Ellipse Fill="{TemplateBinding Background}" Stroke="{TemplateBinding BorderBrush}" StrokeThickness="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=BorderThickness, Mode=OneWay, Converter={StaticResource ThicknessToDoubleConverter}}" />
                <Ellipse x:Name="CheckBullet" Fill="{StaticResource AccentBrush}" StrokeThickness="0" Visibility="Collapsed" HorizontalAlignment="Center" VerticalAlignment="Center" Width="{TemplateBinding params:Bullet.Size}" Height="{TemplateBinding params:Bullet.Size}"></Ellipse>
              </Grid>
            </BulletDecorator.Bullet>
            <Border Margin="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(params:General.BoldPaddingValue), Mode=OneWay, Converter={StaticResource DoubleToThicknessConverter}, ConverterParameter=Left}">
              <ContentPresenter Margin="{TemplateBinding Padding}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" RecognizesAccessKey="True" />
            </Border>
          </BulletDecorator>
          <ControlTemplate.Triggers>
            <Trigger Property="IsChecked" Value="True">
              <Setter TargetName="CheckBullet" Property="Visibility" Value="Visible" />
            </Trigger>
            <Trigger Property="IsEnabled" Value="False">
              <Setter TargetName="CheckBullet" Property="Ellipse.Fill" Value="{StaticResource DisabledBrush}" />
            </Trigger>
          </ControlTemplate.Triggers>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
    <Style.Triggers>
      <Trigger Property="IsMouseOver" Value="True">
        <Setter Property="Background" Value="{StaticResource HighlightBrush}" />
        <Setter Property="BorderBrush" Value="{StaticResource MiddleLightBrush}" />
      </Trigger>
      <Trigger Property="IsPressed" Value="True">
        <Setter Property="Background" Value="{StaticResource HighlightBrush}" />
        <Setter Property="BorderBrush" Value="{StaticResource LowlightBrush}" />
      </Trigger>
      <Trigger Property="IsEnabled" Value="False">
        <Setter Property="Background" Value="{StaticResource BackgroundBrush}" />
        <Setter Property="BorderBrush" Value="{StaticResource DisabledBrush}" />
        <Setter Property="Foreground" Value="{StaticResource DisabledBrush}" />
      </Trigger>
    </Style.Triggers>
  </Style>
  <Style x:Key="ScrollBarLineDownButtonStyle" TargetType="{x:Type RepeatButton}">
    <Setter Property="Background" Value="{StaticResource TransparentBrush}" />
    <Setter Property="BorderBrush" Value="{StaticResource MiddleLightBrush}" />
    <Setter Property="BorderThickness" Value="{Binding RelativeSource={RelativeSource Self}, Path=(params:General.DefaultThickness), Mode=OneWay}" />
    <Setter Property="FocusVisualStyle" Value="{x:Null}" />
    <Setter Property="Focusable" Value="False" />
    <Setter Property="Stylus.IsFlicksEnabled" Value="False" />
    <Setter Property="Stylus.IsPressAndHoldEnabled" Value="False" />
    <!-- Temporary removed to fix bugs 1144, 1174, 1216 -->
    <!--<Setter Property="OverridesDefaultStyle" Value="True"/>-->
    <Setter Property="SnapsToDevicePixels" Value="True" />
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type RepeatButton}">
          <Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding Background}" BorderThickness="{TemplateBinding BorderThickness}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">
            <Polygon Points="0,0 3,4 6,0" Fill="{TemplateBinding BorderBrush}" StrokeThickness="0" Stretch="Uniform" Width="{Binding RelativeSource={RelativeSource AncestorType={x:Type ScrollBar}}, Path=(params:ScrollBar.ArrowSize), Mode=OneWay}" Height="{Binding RelativeSource={RelativeSource AncestorType={x:Type ScrollBar}}, Path=(params:ScrollBar.ArrowSize), Mode=OneWay}" />
          </Border>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
    <Style.Triggers>
      <Trigger Property="IsMouseOver" Value="True">
        <Setter Property="BorderBrush" Value="{StaticResource LowlightBrush}" />
      </Trigger>
      <Trigger Property="IsPressed" Value="True">
        <Setter Property="BorderBrush" Value="{StaticResource ForegroundBrush}" />
      </Trigger>
      <Trigger Property="IsEnabled" Value="False">
        <Setter Property="BorderBrush" Value="{StaticResource DisabledBrush}" />
      </Trigger>
    </Style.Triggers>
  </Style>
  <Style x:Key="ScrollBarLineUpButtonStyle" TargetType="{x:Type RepeatButton}" BasedOn="{StaticResource ScrollBarLineDownButtonStyle}">
    <Setter Property="LayoutTransform">
      <Setter.Value>
        <RotateTransform Angle="180" />
      </Setter.Value>
    </Setter>
  </Style>
  <Style x:Key="ScrollBarLineLeftButtonStyle" TargetType="{x:Type RepeatButton}" BasedOn="{StaticResource ScrollBarLineDownButtonStyle}">
    <Setter Property="LayoutTransform">
      <Setter.Value>
        <RotateTransform Angle="-90" />
      </Setter.Value>
    </Setter>
  </Style>
  <Style x:Key="ScrollBarLineRightButtonStyle" TargetType="{x:Type RepeatButton}" BasedOn="{StaticResource ScrollBarLineDownButtonStyle}">
    <Setter Property="LayoutTransform">
      <Setter.Value>
        <RotateTransform Angle="90" />
      </Setter.Value>
    </Setter>
  </Style>
  <Style x:Key="ScrollBarPageButtonStyle" TargetType="{x:Type RepeatButton}">
    <Setter Property="Background" Value="{StaticResource TransparentBrush}" />
    <Setter Property="BorderBrush" Value="{StaticResource TransparentBrush}" />
    <Setter Property="BorderThickness" Value="0" />
    <Setter Property="FocusVisualStyle" Value="{x:Null}" />
    <Setter Property="Focusable" Value="False" />
    <Setter Property="Stylus.IsFlicksEnabled" Value="False" />
    <Setter Property="Stylus.IsPressAndHoldEnabled" Value="False" />
    <!-- Temporary removed to fix bugs 1144, 1174, 1216 -->
    <!--<Setter Property="OverridesDefaultStyle" Value="True"/>-->
    <Setter Property="SnapsToDevicePixels" Value="True" />
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type RepeatButton}">
          <Rectangle Fill="{TemplateBinding Background}" Stroke="{TemplateBinding BorderBrush}" StrokeThickness="0" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>
  <Style x:Key="ScrollBarThumbStyle" TargetType="{x:Type Thumb}">
    <Setter Property="Background" Value="{StaticResource MiddleLightBrush}" />
    <Setter Property="BorderBrush" Value="{StaticResource TransparentBrush}" />
    <Setter Property="BorderThickness" Value="0" />
    <Setter Property="FocusVisualStyle" Value="{x:Null}" />
    <Setter Property="Focusable" Value="False" />
    <Setter Property="Stylus.IsFlicksEnabled" Value="False" />
    <Setter Property="Stylus.IsPressAndHoldEnabled" Value="False" />
    <Setter Property="Padding" Value="{Binding RelativeSource={RelativeSource Self}, Path=(params:General.DefaultPaddingValue), Mode=OneWay, Converter={StaticResource DoubleToThicknessConverter}, ConverterParameter=Left}" />
    <!-- Temporary removed to fix bugs 1144, 1174, 1216 -->
    <!--<Setter Property="OverridesDefaultStyle" Value="True"/>-->
    <Setter Property="SnapsToDevicePixels" Value="True" />
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type Thumb}">
          <Grid SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">
            <Rectangle Fill="{TemplateBinding Background}" Stroke="{TemplateBinding BorderBrush}" StrokeThickness="0" Margin="{TemplateBinding Padding}" />
          </Grid>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
    <Style.Triggers>
      <Trigger Property="IsMouseOver" Value="True">
        <Setter Property="Background" Value="{StaticResource LowlightBrush}" />
      </Trigger>
      <Trigger Property="IsDragging" Value="True">
        <Setter Property="Background" Value="{StaticResource ForegroundBrush}" />
      </Trigger>
      <Trigger Property="IsEnabled" Value="False">
        <Setter Property="Background" Value="{StaticResource DisabledBrush}" />
      </Trigger>
    </Style.Triggers>
  </Style>
  <ControlTemplate x:Key="HorizontalScrollBarTemplate" TargetType="{x:Type ScrollBar}">
    <Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">
      <Grid>
        <Grid.ColumnDefinitions>
          <ColumnDefinition Width="Auto" />
          <ColumnDefinition Width="*" />
          <ColumnDefinition Width="Auto" />
        </Grid.ColumnDefinitions>
        <RepeatButton Grid.Column="0" Command="{x:Static ScrollBar.LineLeftCommand}" IsEnabled="{TemplateBinding IsEnabled}" Style="{StaticResource ScrollBarLineLeftButtonStyle}" Visibility="Collapsed" />
        <Track x:Name="PART_Track" Grid.Column="1">
          <Track.DecreaseRepeatButton>
            <RepeatButton Command="{x:Static ScrollBar.PageLeftCommand}" IsEnabled="{TemplateBinding IsEnabled}" Style="{StaticResource ScrollBarPageButtonStyle}" />
          </Track.DecreaseRepeatButton>
          <Track.Thumb>
            <Thumb IsEnabled="{TemplateBinding IsEnabled}" Style="{StaticResource ScrollBarThumbStyle}" />
          </Track.Thumb>
          <Track.IncreaseRepeatButton>
            <RepeatButton Command="{x:Static ScrollBar.PageRightCommand}" IsEnabled="{TemplateBinding IsEnabled}" Style="{StaticResource ScrollBarPageButtonStyle}" />
          </Track.IncreaseRepeatButton>
        </Track>
        <RepeatButton Grid.Column="2" Command="{x:Static ScrollBar.LineRightCommand}" IsEnabled="{TemplateBinding IsEnabled}" Style="{StaticResource ScrollBarLineRightButtonStyle}" Visibility="Collapsed" />
      </Grid>
    </Border>
  </ControlTemplate>
  <ControlTemplate x:Key="VerticalScrollBarTemplate" TargetType="{x:Type ScrollBar}">
    <Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">
      <Grid>
        <Grid.RowDefinitions>
          <RowDefinition Height="Auto" />
          <RowDefinition Height="*" />
          <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        <RepeatButton Grid.Row="0" Command="{x:Static ScrollBar.LineUpCommand}" IsEnabled="{TemplateBinding IsEnabled}" Style="{StaticResource ScrollBarLineUpButtonStyle}" Visibility="Collapsed" />
        <Track x:Name="PART_Track" Grid.Row="1" IsDirectionReversed="True">
          <Track.DecreaseRepeatButton>
            <RepeatButton Command="{x:Static ScrollBar.PageUpCommand}" IsEnabled="{TemplateBinding IsEnabled}" Style="{StaticResource ScrollBarPageButtonStyle}" />
          </Track.DecreaseRepeatButton>
          <Track.Thumb>
            <Thumb IsEnabled="{TemplateBinding IsEnabled}" Style="{StaticResource ScrollBarThumbStyle}" />
          </Track.Thumb>
          <Track.IncreaseRepeatButton>
            <RepeatButton Command="{x:Static ScrollBar.PageDownCommand}" IsEnabled="{TemplateBinding IsEnabled}" Style="{StaticResource ScrollBarPageButtonStyle}" />
          </Track.IncreaseRepeatButton>
        </Track>
        <RepeatButton Grid.Row="2" Command="{x:Static ScrollBar.LineDownCommand}" IsEnabled="{TemplateBinding IsEnabled}" Style="{StaticResource ScrollBarLineDownButtonStyle}" Visibility="Collapsed" />
      </Grid>
    </Border>
  </ControlTemplate>
  <Style TargetType="{x:Type ScrollBar}">
    <Setter Property="Background" Value="{StaticResource TransparentBrush}" />
    <Setter Property="BorderBrush" Value="{StaticResource MiddleLightBrush}" />
    <Setter Property="FocusVisualStyle" Value="{x:Null}" />
    <Setter Property="Focusable" Value="False" />
    <Setter Property="Stylus.IsFlicksEnabled" Value="False" />
    <Setter Property="Stylus.IsPressAndHoldEnabled" Value="False" />
    <Setter Property="SnapsToDevicePixels" Value="True" />
    <Style.Triggers>
      <Trigger Property="Orientation" Value="Horizontal">
        <Setter Property="BorderThickness" Value="{Binding RelativeSource={RelativeSource Self}, Path=(params:General.DefaultPaddingValue), Mode=OneWay, Converter={StaticResource DoubleToThicknessConverter}, ConverterParameter=Bottom}" />
        <Setter Property="MinHeight" Value="6" />
        <Setter Property="Height" Value="6" />
        <Setter Property="MaxHeight" Value="10" />
        <Setter Property="Template" Value="{StaticResource HorizontalScrollBarTemplate}" />
      </Trigger>
      <Trigger Property="Orientation" Value="Vertical">
        <Setter Property="BorderThickness" Value="{Binding RelativeSource={RelativeSource Self}, Path=(params:General.DefaultPaddingValue), Mode=OneWay, Converter={StaticResource DoubleToThicknessConverter}, ConverterParameter=Right}" />
        <Setter Property="MinWidth" Value="6" />
        <Setter Property="Width" Value="6" />
        <Setter Property="MaxWidth" Value="10" />
        <Setter Property="Template" Value="{StaticResource VerticalScrollBarTemplate}" />
      </Trigger>
    </Style.Triggers>
  </Style>
  <Style TargetType="{x:Type ScrollViewer}">
    <Setter Property="Background" Value="{StaticResource BackgroundBrush}" />
    <Setter Property="BorderBrush" Value="{StaticResource MiddleLightBrush}" />
    <Setter Property="BorderThickness" Value="0" />
    <Setter Property="Foreground" Value="{StaticResource ForegroundBrush}" />
    <Setter Property="FontSize" Value="{Binding RelativeSource={RelativeSource Self}, Path=(params:General.TextFontSize), Mode=OneWay}" />
    <Setter Property="FontStretch" Value="Medium" />
    <Setter Property="FontStyle" Value="Normal" />
    <Setter Property="FontWeight" Value="Normal" />
    <Setter Property="TextOptions.TextFormattingMode" Value="Display" />
    <Setter Property="TextOptions.TextRenderingMode" Value="ClearType" />
    <Setter Property="RenderOptions.ClearTypeHint" Value="Enabled" />
    <Setter Property="HorizontalContentAlignment" Value="Stretch" />
    <Setter Property="VerticalContentAlignment" Value="Stretch" />
    <Setter Property="Padding" Value="0" />
    <!-- Temporary removed to fix bugs 1144, 1174, 1216 -->
    <!--<Setter Property="OverridesDefaultStyle" Value="True"/>-->
    <Setter Property="SnapsToDevicePixels" Value="True" />
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type ScrollViewer}">
          <Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" TextBlock.Foreground="{TemplateBinding Foreground}" TextBlock.FontSize="{TemplateBinding FontSize}" TextBlock.FontStretch="{TemplateBinding FontStretch}" TextBlock.FontStyle="{TemplateBinding FontStyle}" TextBlock.FontWeight="{TemplateBinding FontWeight}" TextOptions.TextFormattingMode="{TemplateBinding TextOptions.TextFormattingMode}" TextOptions.TextRenderingMode="{TemplateBinding TextOptions.TextRenderingMode}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">
            <Grid>
              <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="Auto" />
              </Grid.ColumnDefinitions>
              <Grid.RowDefinitions>
                <RowDefinition Height="*" />
                <RowDefinition Height="Auto" />
              </Grid.RowDefinitions>
              <ScrollContentPresenter x:Name="PART_ScrollContentPresenter" Grid.Column="0" Grid.Row="0" Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}" CanContentScroll="{TemplateBinding CanContentScroll}" CanHorizontallyScroll="False" CanVerticallyScroll="False" Margin="{TemplateBinding Padding}" />
              <ScrollBar x:Name="PART_HorizontalScrollBar" Grid.Column="0" Grid.Row="1" AutomationProperties.AutomationId="HorizontalScrollBar" Cursor="Arrow" Orientation="Horizontal" Minimum="0" Maximum="{TemplateBinding ScrollableWidth}" Value="{TemplateBinding HorizontalOffset}" ViewportSize="{TemplateBinding ViewportWidth}" Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}" />
              <ScrollBar x:Name="PART_VerticalScrollBar" Grid.Column="1" Grid.Row="0" AutomationProperties.AutomationId="VerticalScrollBar" Cursor="Arrow" Orientation="Vertical" Minimum="0" Maximum="{TemplateBinding ScrollableHeight}" Value="{TemplateBinding VerticalOffset}" ViewportSize="{TemplateBinding ViewportHeight}" Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}" />
            </Grid>
          </Border>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
    <Style.Triggers>
      <DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=FontSize, Mode=OneWay, Converter={StaticResource IsGreaterThanConverter}, ConverterParameter=18}">
        <Setter Property="TextOptions.TextFormattingMode" Value="Ideal" />
      </DataTrigger>
    </Style.Triggers>
  </Style>
  <Style x:Key="{x:Static MenuItem.SeparatorStyleKey}" TargetType="{x:Type Separator}">
    <Setter Property="Background" Value="{StaticResource TransparentBrush}" />
    <Setter Property="BorderBrush" Value="{StaticResource HighlightBrush}" />
    <Setter Property="BorderThickness" Value="{Binding RelativeSource={RelativeSource Self}, Path=(params:General.DefaultThickness), Mode=OneWay}" />
    <Setter Property="Focusable" Value="False" />
    <Setter Property="FocusVisualStyle" Value="{x:Null}" />
    <Setter Property="HorizontalContentAlignment" Value="Stretch" />
    <Setter Property="VerticalContentAlignment" Value="Stretch" />
    <Setter Property="Padding" Value="{Binding RelativeSource={RelativeSource Self}, Path=(params:General.BoldPaddingValue), Mode=OneWay}" />
    <!-- Temporary removed to fix bugs 1144, 1174, 1216 -->
    <!--<Setter Property="OverridesDefaultStyle" Value="True"/>-->
    <Setter Property="SnapsToDevicePixels" Value="True" />
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type Separator}">
          <Border Background="{TemplateBinding Background}" BorderThickness="0" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">
            <Line Stroke="{TemplateBinding BorderBrush}" StrokeThickness="{Binding BorderThickness, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource ThicknessToDoubleConverter}}" X1="0" Y1="0" X2="1" Y2="0" Stretch="Fill" Margin="{TemplateBinding Padding}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
          </Border>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>
  <ControlTemplate x:Key="{x:Static MenuItem.TopLevelHeaderTemplateKey}" TargetType="{x:Type MenuItem}">
    <Border x:Name="LayoutRoot" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">
      <Grid x:Name="ContentHost" TextBlock.Foreground="{TemplateBinding Foreground}" TextBlock.FontFamily="{TemplateBinding FontFamily}" TextBlock.FontSize="{TemplateBinding FontSize}" TextBlock.FontStretch="{TemplateBinding FontStretch}" TextBlock.FontStyle="{TemplateBinding FontStyle}" TextBlock.FontWeight="{TemplateBinding FontWeight}" TextOptions.TextFormattingMode="{TemplateBinding TextOptions.TextFormattingMode}" TextOptions.TextRenderingMode="{TemplateBinding TextOptions.TextRenderingMode}" RenderOptions.ClearTypeHint="{TemplateBinding RenderOptions.ClearTypeHint}">
        <ContentPresenter x:Name="HeaderHost" ContentSource="Header" RecognizesAccessKey="True" Margin="{TemplateBinding Padding}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
        <Popup x:Name="PART_Popup" Grid.IsSharedSizeScope="True" AllowsTransparency="True" Focusable="False" IsOpen="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=IsSubmenuOpen, Mode=TwoWay}" Placement="Custom" PlacementTarget="{Binding ElementName=LayoutRoot}" CustomPopupPlacementCallback="{x:Static params:DropDown.PopupPlacementCallback}">
          <Border x:Name="PopupRoot" Tag="{DynamicResource {x:Static SystemParameters.DropShadowKey}}" SnapsToDevicePixels="True">
            <Grid>
              <Border Background="{Binding RelativeSource={RelativeSource AncestorType={x:Type MenuBase}}, Path=(params:MenuBase.SubmenuBackground)}" BorderBrush="{Binding RelativeSource={RelativeSource AncestorType={x:Type MenuBase}}, Path=(params:MenuBase.SubmenuBorderBrush)}" BorderThickness="{Binding RelativeSource={RelativeSource AncestorType={x:Type MenuBase}}, Path=(params:MenuBase.SubmenuBorderThickness)}" TextBlock.Foreground="{Binding RelativeSource={RelativeSource AncestorType={x:Type MenuBase}}, Path=Foreground}" TextBlock.FontFamily="{Binding RelativeSource={RelativeSource AncestorType={x:Type MenuBase}}, Path=FontFamily}" TextBlock.FontSize="{Binding RelativeSource={RelativeSource AncestorType={x:Type MenuBase}}, Path=FontSize}" TextBlock.FontStretch="{Binding RelativeSource={RelativeSource AncestorType={x:Type MenuBase}}, Path=FontStretch}" TextBlock.FontStyle="{Binding RelativeSource={RelativeSource AncestorType={x:Type MenuBase}}, Path=FontStyle}" TextBlock.FontWeight="{Binding RelativeSource={RelativeSource AncestorType={x:Type MenuBase}}, Path=FontWeight}" TextOptions.TextFormattingMode="{Binding RelativeSource={RelativeSource AncestorType={x:Type MenuBase}}, Path=(TextOptions.TextFormattingMode)}" TextOptions.TextRenderingMode="{Binding RelativeSource={RelativeSource AncestorType={x:Type MenuBase}}, Path=(TextOptions.TextRenderingMode)}" RenderOptions.ClearTypeHint="{Binding RelativeSource={RelativeSource AncestorType={x:Type MenuBase}}, Path=(RenderOptions.ClearTypeHint)}" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
                <StackPanel IsItemsHost="True" KeyboardNavigation.DirectionalNavigation="Cycle" />
              </Border>
              <Rectangle x:Name="PopupMask" Fill="{Binding RelativeSource={RelativeSource AncestorType={x:Type MenuBase}}, Path=(params:MenuBase.SubmenuBackground)}" Margin="{Binding RelativeSource={RelativeSource AncestorType={x:Type MenuBase}}, Path=(params:MenuBase.SubmenuBorderThickness), Converter={StaticResource ThicknessConverter}, ConverterParameter='Left'}" HorizontalAlignment="Left" VerticalAlignment="Top" Width="{Binding ElementName=ContentHost, Path=ActualWidth}" />
            </Grid>
          </Border>
        </Popup>
      </Grid>
    </Border>
    <ControlTemplate.Triggers>
      <Trigger Property="IsSubmenuOpen" Value="True">
        <Setter TargetName="PART_Popup" Property="params:DropDown.IsOpen" Value="True" />
      </Trigger>
      <Trigger SourceName="PART_Popup" Property="IsOpen" Value="True">
        <Setter TargetName="LayoutRoot" Property="Background" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type MenuBase}}, Path=(params:MenuBase.SubmenuBackground)}" />
        <Setter TargetName="LayoutRoot" Property="BorderBrush" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type MenuBase}}, Path=(params:MenuBase.SubmenuBorderBrush)}" />
      </Trigger>
      <MultiTrigger>
        <MultiTrigger.Conditions>
          <Condition SourceName="PART_Popup" Property="IsOpen" Value="True" />
          <Condition SourceName="PART_Popup" Property="params:DropDown.IsDefaultHorizontalPosition" Value="True" />
          <Condition SourceName="PART_Popup" Property="params:DropDown.IsDefaultVerticalPosition" Value="True" />
        </MultiTrigger.Conditions>
        <MultiTrigger.Setters>
          <Setter TargetName="LayoutRoot" Property="BorderThickness" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type MenuBase}}, Path=(params:MenuBase.SubmenuBorderThickness), Converter={StaticResource ThicknessConverter}, ConverterParameter='Left, Top, Right'}" />
          <Setter TargetName="PopupMask" Property="Height" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type MenuBase}}, Path=(params:MenuBase.SubmenuBorderThickness), Converter={StaticResource ThicknessToDoubleConverter}, ConverterParameter='Top'}" />
        </MultiTrigger.Setters>
      </MultiTrigger>
      <MultiTrigger>
        <MultiTrigger.Conditions>
          <Condition SourceName="PART_Popup" Property="IsOpen" Value="True" />
          <Condition SourceName="PART_Popup" Property="params:DropDown.IsDefaultHorizontalPosition" Value="True" />
          <Condition SourceName="PART_Popup" Property="params:DropDown.IsDefaultVerticalPosition" Value="False" />
        </MultiTrigger.Conditions>
        <MultiTrigger.Setters>
          <Setter TargetName="LayoutRoot" Property="BorderThickness" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type MenuBase}}, Path=(params:MenuBase.SubmenuBorderThickness), Converter={StaticResource ThicknessConverter}, ConverterParameter='Left, Right, Bottom'}" />
          <Setter TargetName="PopupMask" Property="Height" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type MenuBase}}, Path=(params:MenuBase.SubmenuBorderThickness), Converter={StaticResource ThicknessToDoubleConverter}, ConverterParameter='Bottom'}" />
          <Setter TargetName="PopupMask" Property="VerticalAlignment" Value="Bottom" />
        </MultiTrigger.Setters>
      </MultiTrigger>
      <MultiDataTrigger>
        <MultiDataTrigger.Conditions>
          <Condition Binding="{Binding ElementName=PopupRoot, Path=Tag}" Value="True" />
          <Condition Binding="{Binding ElementName=PART_Popup, Path=(params:DropDown.IsDefaultVerticalPosition)}" Value="True" />
        </MultiDataTrigger.Conditions>
        <MultiDataTrigger.Setters>
          <Setter TargetName="PopupRoot" Property="Effect">
            <Setter.Value>
              <DropShadowEffect Color="{Binding RelativeSource={RelativeSource AncestorType={x:Type MenuBase}}, Path=(params:General.ShadowBrush).(SolidColorBrush.Color)}" BlurRadius="4" ShadowDepth="2" Direction="315" Opacity="0.3" />
            </Setter.Value>
          </Setter>
          <Setter TargetName="PopupRoot" Property="Background" Value="{StaticResource TransparentBrush}" />
          <Setter TargetName="PopupRoot" Property="Padding" Value="0,0,6,6" />
        </MultiDataTrigger.Setters>
      </MultiDataTrigger>
      <MultiDataTrigger>
        <MultiDataTrigger.Conditions>
          <Condition Binding="{Binding ElementName=PopupRoot, Path=Tag}" Value="True" />
          <Condition Binding="{Binding ElementName=PART_Popup, Path=(params:DropDown.IsDefaultVerticalPosition)}" Value="False" />
        </MultiDataTrigger.Conditions>
        <MultiDataTrigger.Setters>
          <Setter TargetName="PopupRoot" Property="Effect">
            <Setter.Value>
              <DropShadowEffect Color="{Binding RelativeSource={RelativeSource AncestorType={x:Type MenuBase}}, Path=(params:General.ShadowBrush).(SolidColorBrush.Color)}" BlurRadius="4" ShadowDepth="0" Direction="45" Opacity="0.3" />
            </Setter.Value>
          </Setter>
          <Setter TargetName="PopupRoot" Property="Background" Value="{StaticResource TransparentBrush}" />
          <Setter TargetName="PopupRoot" Property="Padding" Value="0,4,4,0" />
        </MultiDataTrigger.Setters>
      </MultiDataTrigger>
    </ControlTemplate.Triggers>
  </ControlTemplate>
  <ControlTemplate x:Key="{x:Static MenuItem.TopLevelItemTemplateKey}" TargetType="{x:Type MenuItem}">
    <Border x:Name="LayoutRoot" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" TextBlock.Foreground="{TemplateBinding Foreground}" TextBlock.FontFamily="{TemplateBinding FontFamily}" TextBlock.FontSize="{TemplateBinding FontSize}" TextBlock.FontStretch="{TemplateBinding FontStretch}" TextBlock.FontStyle="{TemplateBinding FontStyle}" TextBlock.FontWeight="{TemplateBinding FontWeight}" TextOptions.TextFormattingMode="{TemplateBinding TextOptions.TextFormattingMode}" TextOptions.TextRenderingMode="{TemplateBinding TextOptions.TextRenderingMode}" RenderOptions.ClearTypeHint="{TemplateBinding RenderOptions.ClearTypeHint}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">
      <ContentPresenter x:Name="HeaderHost" ContentSource="Header" RecognizesAccessKey="True" Margin="{TemplateBinding Padding}" />
    </Border>
  </ControlTemplate>
  <ControlTemplate x:Key="{x:Static MenuItem.SubmenuHeaderTemplateKey}" TargetType="{x:Type MenuItem}">
    <Border x:Name="LayoutRoot" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">
      <Grid TextBlock.Foreground="{TemplateBinding Foreground}" TextBlock.FontFamily="{TemplateBinding FontFamily}" TextBlock.FontSize="{TemplateBinding FontSize}" TextBlock.FontStretch="{TemplateBinding FontStretch}" TextBlock.FontStyle="{TemplateBinding FontStyle}" TextBlock.FontWeight="{TemplateBinding FontWeight}" TextOptions.TextFormattingMode="{TemplateBinding TextOptions.TextFormattingMode}" TextOptions.TextRenderingMode="{TemplateBinding TextOptions.TextRenderingMode}" RenderOptions.ClearTypeHint="{TemplateBinding RenderOptions.ClearTypeHint}" Margin="{TemplateBinding Padding}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}">
        <Grid.ColumnDefinitions>
          <ColumnDefinition Width="Auto" SharedSizeGroup="ContextMenuIconSizeGroup" />
          <ColumnDefinition Width="*" />
          <ColumnDefinition Width="Auto" />
        </Grid.ColumnDefinitions>
        <ContentPresenter x:Name="IconHost" Grid.Column="0" ContentSource="Icon" HorizontalAlignment="Left" VerticalAlignment="Center" MinWidth="16" MinHeight="16" />
        <ContentPresenter x:Name="HeaderHost" Grid.Column="1" ContentSource="Header" RecognizesAccessKey="True" Margin="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(params:General.BoldPaddingValue), Mode=OneWay, Converter={StaticResource DoubleToThicknessConverter}, ConverterParameter='Left, Right'}" HorizontalAlignment="Left" VerticalAlignment="Center" />
        <Polygon x:Name="ArrowGlyph" Grid.Column="2" Fill="{StaticResource MiddleLightBrush}" StrokeThickness="0" Stretch="Uniform" Margin="{TemplateBinding params:MenuItem.ArrowMargin}" HorizontalAlignment="Right" VerticalAlignment="Center" Width="{TemplateBinding params:MenuItem.ArrowSize}" Height="{TemplateBinding params:MenuItem.ArrowSize}">
          <Polygon.Points>
            <PointCollection>
              <Point X="0" Y="0" />
              <Point X="2" Y="2" />
              <Point X="0" Y="4" />
            </PointCollection>
          </Polygon.Points>
        </Polygon>
        <Popup x:Name="PART_Popup" Grid.Column="0" Grid.IsSharedSizeScope="True" AllowsTransparency="True" Focusable="False" Placement="Right" PlacementTarget="{Binding ElementName=LayoutRoot}" IsOpen="{TemplateBinding IsSubmenuOpen}" PopupAnimation="{DynamicResource {x:Static SystemParameters.MenuPopupAnimationKey}}" Tag="{DynamicResource {x:Static SystemParameters.MenuAnimationKey}}">
          <Border x:Name="PopupRoot" Tag="{DynamicResource {x:Static SystemParameters.DropShadowKey}}">
            <Border Background="{Binding RelativeSource={RelativeSource AncestorType={x:Type MenuBase}}, Path=(params:MenuBase.SubmenuBackground)}" BorderBrush="{Binding RelativeSource={RelativeSource AncestorType={x:Type MenuBase}}, Path=(params:MenuBase.SubmenuBorderBrush)}" BorderThickness="{Binding RelativeSource={RelativeSource AncestorType={x:Type MenuBase}}, Path=(params:MenuBase.SubmenuBorderThickness)}" TextBlock.Foreground="{Binding RelativeSource={RelativeSource AncestorType={x:Type MenuBase}}, Path=Foreground}" TextBlock.FontFamily="{Binding RelativeSource={RelativeSource AncestorType={x:Type MenuBase}}, Path=FontFamily}" TextBlock.FontSize="{Binding RelativeSource={RelativeSource AncestorType={x:Type MenuBase}}, Path=FontSize}" TextBlock.FontStretch="{Binding RelativeSource={RelativeSource AncestorType={x:Type MenuBase}}, Path=FontStretch}" TextBlock.FontStyle="{Binding RelativeSource={RelativeSource AncestorType={x:Type MenuBase}}, Path=FontStyle}" TextBlock.FontWeight="{Binding RelativeSource={RelativeSource AncestorType={x:Type MenuBase}}, Path=FontWeight}" TextOptions.TextFormattingMode="{Binding RelativeSource={RelativeSource AncestorType={x:Type MenuBase}}, Path=(TextOptions.TextFormattingMode)}" TextOptions.TextRenderingMode="{Binding RelativeSource={RelativeSource AncestorType={x:Type MenuBase}}, Path=(TextOptions.TextRenderingMode)}" RenderOptions.ClearTypeHint="{Binding RelativeSource={RelativeSource AncestorType={x:Type MenuBase}}, Path=(RenderOptions.ClearTypeHint)}" SnapsToDevicePixels="{Binding RelativeSource={RelativeSource AncestorType={x:Type MenuBase}}, Path=SnapsToDevicePixels}">
              <StackPanel IsItemsHost="True" KeyboardNavigation.DirectionalNavigation="Cycle" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />
            </Border>
          </Border>
        </Popup>
      </Grid>
    </Border>
    <ControlTemplate.Triggers>
      <Trigger Property="Icon" Value="{x:Null}">
        <Setter TargetName="IconHost" Property="Visibility" Value="Collapsed" />
      </Trigger>
      <Trigger Property="IsSubmenuOpen" Value="True">
        <Setter TargetName="ArrowGlyph" Property="Fill" Value="{StaticResource AccentBrush}" />
      </Trigger>
      <Trigger Property="IsSuspendingPopupAnimation" Value="True">
        <Setter TargetName="PART_Popup" Property="PopupAnimation" Value="None" />
      </Trigger>
      <Trigger SourceName="PART_Popup" Property="Tag" Value="False">
        <Setter TargetName="PART_Popup" Property="PopupAnimation" Value="None" />
      </Trigger>
      <DataTrigger Binding="{Binding ElementName=PopupRoot, Path=Tag}" Value="True">
        <Setter TargetName="PopupRoot" Property="Effect">
          <Setter.Value>
            <DropShadowEffect Color="{Binding RelativeSource={RelativeSource AncestorType={x:Type MenuBase}}, Path=(params:General.ShadowBrush).(SolidColorBrush.Color)}" BlurRadius="4" ShadowDepth="2" Direction="315" Opacity="0.3" />
          </Setter.Value>
        </Setter>
        <Setter TargetName="PopupRoot" Property="Background" Value="{StaticResource TransparentBrush}" />
        <Setter TargetName="PopupRoot" Property="Padding" Value="0,0,6,6" />
      </DataTrigger>
    </ControlTemplate.Triggers>
  </ControlTemplate>
  <ControlTemplate x:Key="{x:Static MenuItem.SubmenuItemTemplateKey}" TargetType="{x:Type MenuItem}">
    <Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">
      <Grid TextBlock.Foreground="{TemplateBinding Foreground}" TextBlock.FontFamily="{TemplateBinding FontFamily}" TextBlock.FontSize="{TemplateBinding FontSize}" TextBlock.FontStretch="{TemplateBinding FontStretch}" TextBlock.FontStyle="{TemplateBinding FontStyle}" TextBlock.FontWeight="{TemplateBinding FontWeight}" TextOptions.TextFormattingMode="{TemplateBinding TextOptions.TextFormattingMode}" TextOptions.TextRenderingMode="{TemplateBinding TextOptions.TextRenderingMode}" RenderOptions.ClearTypeHint="{TemplateBinding RenderOptions.ClearTypeHint}" Margin="{TemplateBinding Padding}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}">
        <Grid.ColumnDefinitions>
          <ColumnDefinition Width="Auto" SharedSizeGroup="ContextMenuIconSizeGroup" />
          <ColumnDefinition Width="*" />
          <ColumnDefinition Width="Auto" SharedSizeGroup="ContextMenuShortcutSizeGroup" />
        </Grid.ColumnDefinitions>
        <Path x:Name="CheckBullet" Grid.Column="0" Stroke="{StaticResource LowlightBrush}" StrokeThickness="{TemplateBinding params:General.BoldThicknessValue}" Stretch="Uniform" Visibility="Collapsed" HorizontalAlignment="Center" VerticalAlignment="Center" Width="{TemplateBinding params:MenuItem.BulletSize}" Height="{TemplateBinding params:MenuItem.BulletSize}">
          <Path.Data>
            <GeometryGroup>
              <LineGeometry StartPoint="0,3" EndPoint="4,8" />
              <LineGeometry StartPoint="4,8" EndPoint="8,0" />
            </GeometryGroup>
          </Path.Data>
        </Path>
        <ContentPresenter x:Name="IconHost" Grid.Column="0" ContentSource="Icon" HorizontalAlignment="Left" VerticalAlignment="Center" MinWidth="16" MinHeight="16" />
        <ContentPresenter x:Name="HeaderHost" Grid.Column="1" ContentSource="Header" RecognizesAccessKey="True" Margin="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(params:General.BoldPaddingValue), Mode=OneWay, Converter={StaticResource DoubleToThicknessConverter}, ConverterParameter='Left, Right'}" HorizontalAlignment="Left" VerticalAlignment="Center" />
        <TextBlock Grid.Column="2" Text="{TemplateBinding InputGestureText}" Margin="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(params:General.BoldPaddingValue), Mode=OneWay, Converter={StaticResource DoubleToThicknessConverter}, ConverterParameter='Left, Right'}" HorizontalAlignment="Left" VerticalAlignment="Center" />
      </Grid>
    </Border>
    <ControlTemplate.Triggers>
      <Trigger Property="Icon" Value="{x:Null}">
        <Setter TargetName="IconHost" Property="Visibility" Value="Collapsed" />
      </Trigger>
      <Trigger Property="IsCheckable" Value="True">
        <Setter TargetName="IconHost" Property="Visibility" Value="Collapsed" />
      </Trigger>
      <Trigger Property="IsChecked" Value="True">
        <Setter TargetName="CheckBullet" Property="Visibility" Value="Visible" />
      </Trigger>
    </ControlTemplate.Triggers>
  </ControlTemplate>
  <Style TargetType="{x:Type MenuItem}">
    <Setter Property="Background" Value="{StaticResource TransparentBrush}" />
    <Setter Property="BorderBrush" Value="{StaticResource TransparentBrush}" />
    <Setter Property="BorderThickness" Value="0" />
    <Setter Property="Foreground" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type MenuBase}}, Path=Foreground, Mode=OneWay}" />
    <Setter Property="FontFamily" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type MenuBase}}, Path=FontFamily, Mode=OneWay}" />
    <Setter Property="FontSize" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type MenuBase}}, Path=FontSize, Mode=OneWay}" />
    <Setter Property="FontStretch" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type MenuBase}}, Path=FontStretch, Mode=OneWay}" />
    <Setter Property="FontStyle" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type MenuBase}}, Path=FontStyle, Mode=OneWay}" />
    <Setter Property="FontWeight" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type MenuBase}}, Path=FontWeight, Mode=OneWay}" />
    <Setter Property="TextOptions.TextFormattingMode" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type MenuBase}}, Path=(TextOptions.TextFormattingMode), Mode=OneWay}" />
    <Setter Property="TextOptions.TextRenderingMode" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type MenuBase}}, Path=(TextOptions.TextRenderingMode), Mode=OneWay}" />
    <Setter Property="RenderOptions.ClearTypeHint" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type MenuBase}}, Path=(RenderOptions.ClearTypeHint), Mode=OneWay}" />
    <Setter Property="Focusable" Value="True" />
    <Setter Property="FocusVisualStyle" Value="{StaticResource FocusVisualStyle}" />
    <Setter Property="Stylus.IsFlicksEnabled" Value="False" />
    <Setter Property="ScrollViewer.PanningMode" Value="Both" />
    <Setter Property="HorizontalContentAlignment" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type MenuBase}}, Path=HorizontalContentAlignment}" />
    <Setter Property="VerticalContentAlignment" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type MenuBase}}, Path=VerticalContentAlignment}" />
    <Setter Property="Padding" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type MenuBase}}, Path=Padding, Mode=OneWay}" />
    <!-- Temporary removed to fix bugs 1144, 1174, 1216 -->
    <!--<Setter Property="OverridesDefaultStyle" Value="True"/>-->
    <Setter Property="SnapsToDevicePixels" Value="True" />
    <Style.Triggers>
      <Trigger Property="Role" Value="TopLevelHeader">
        <Setter Property="Template" Value="{StaticResource {x:Static MenuItem.TopLevelHeaderTemplateKey}}" />
        <Setter Property="BorderThickness" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type MenuBase}}, Path=(params:MenuBase.SubmenuBorderThickness), Converter={StaticResource ThicknessConverter}, ConverterParameter='Left, Top, Right'}" />
      </Trigger>
      <Trigger Property="Role" Value="TopLevelItem">
        <Setter Property="Template" Value="{StaticResource {x:Static MenuItem.TopLevelItemTemplateKey}}" />
        <Setter Property="BorderThickness" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type MenuBase}}, Path=(params:MenuBase.SubmenuBorderThickness), Converter={StaticResource ThicknessConverter}, ConverterParameter='Left, Top, Right'}" />
      </Trigger>
      <Trigger Property="Role" Value="SubmenuHeader">
        <Setter Property="Template" Value="{StaticResource {x:Static MenuItem.SubmenuHeaderTemplateKey}}" />
      </Trigger>
      <Trigger Property="Role" Value="SubmenuItem">
        <Setter Property="Template" Value="{StaticResource {x:Static MenuItem.SubmenuItemTemplateKey}}" />
      </Trigger>
      <Trigger Property="IsHighlighted" Value="True">
        <Setter Property="Background" Value="{StaticResource HighlightBrush}" />
        <Setter Property="Foreground" Value="{StaticResource ForegroundBrush}" />
      </Trigger>
      <MultiTrigger>
        <MultiTrigger.Conditions>
          <Condition Property="Role" Value="TopLevelHeader" />
          <Condition Property="IsHighlighted" Value="True" />
        </MultiTrigger.Conditions>
        <MultiTrigger.Setters>
          <Setter Property="Background" Value="{StaticResource HighlightBrush}" />
          <Setter Property="BorderBrush" Value="{StaticResource HighlightBrush}" />
        </MultiTrigger.Setters>
      </MultiTrigger>
      <MultiTrigger>
        <MultiTrigger.Conditions>
          <Condition Property="Role" Value="TopLevelItem" />
          <Condition Property="IsHighlighted" Value="True" />
        </MultiTrigger.Conditions>
        <MultiTrigger.Setters>
          <Setter Property="Background" Value="{StaticResource HighlightBrush}" />
          <Setter Property="BorderBrush" Value="{StaticResource HighlightBrush}" />
        </MultiTrigger.Setters>
      </MultiTrigger>
      <Trigger Property="IsEnabled" Value="False">
        <Setter Property="Foreground" Value="{StaticResource DisabledBrush}" />
      </Trigger>
    </Style.Triggers>
  </Style>
  <Style TargetType="{x:Type Menu}">
    <Setter Property="Background" Value="{StaticResource BackgroundBrush}" />
    <Setter Property="BorderBrush" Value="{StaticResource LowlightBrush}" />
    <Setter Property="BorderThickness" Value="0" />
    <Setter Property="params:MenuBase.SubmenuBackground" Value="{StaticResource BackgroundBrush}" />
    <Setter Property="params:MenuBase.SubmenuBorderBrush" Value="{StaticResource LowlightBrush}" />
    <Setter Property="params:MenuBase.SubmenuBorderThickness" Value="{Binding RelativeSource={RelativeSource Self}, Path=(params:General.DefaultThickness), Mode=OneWay}" />
    <Setter Property="Foreground" Value="{StaticResource ForegroundBrush}" />
    <Setter Property="FontSize" Value="{Binding RelativeSource={RelativeSource Self}, Path=(params:General.ContentFontSize), Mode=OneWay}" />
    <Setter Property="FontStretch" Value="Medium" />
    <Setter Property="FontStyle" Value="Normal" />
    <Setter Property="FontWeight" Value="Normal" />
    <Setter Property="TextOptions.TextFormattingMode" Value="Display" />
    <Setter Property="TextOptions.TextRenderingMode" Value="ClearType" />
    <Setter Property="RenderOptions.ClearTypeHint" Value="Enabled" />
    <Setter Property="params:General.ShadowBrush" Value="{StaticResource ForegroundBrush}" />
    <Setter Property="HorizontalAlignment" Value="Stretch" />
    <Setter Property="VerticalAlignment" Value="Top" />
    <Setter Property="HorizontalContentAlignment" Value="Stretch" />
    <Setter Property="VerticalContentAlignment" Value="Stretch" />
    <Setter Property="Padding" Value="{Binding RelativeSource={RelativeSource Self}, Path=(params:General.BoldPadding), Mode=OneWay}" />
    <!-- Temporary removed to fix bugs 1144, 1174, 1216 -->
    <!--<Setter Property="OverridesDefaultStyle" Value="True"/>-->
    <Setter Property="SnapsToDevicePixels" Value="True" />
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type Menu}">
          <Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" TextBlock.Foreground="{TemplateBinding Foreground}" TextBlock.FontFamily="{TemplateBinding FontFamily}" TextBlock.FontSize="{TemplateBinding FontSize}" TextBlock.FontStretch="{TemplateBinding FontStretch}" TextBlock.FontStyle="{TemplateBinding FontStyle}" TextBlock.FontWeight="{TemplateBinding FontWeight}" TextOptions.TextFormattingMode="{TemplateBinding TextOptions.TextFormattingMode}" TextOptions.TextRenderingMode="{TemplateBinding TextOptions.TextRenderingMode}" RenderOptions.ClearTypeHint="{TemplateBinding RenderOptions.ClearTypeHint}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">
            <ItemsPresenter Margin="{TemplateBinding Padding}" KeyboardNavigation.DirectionalNavigation="Cycle" />
          </Border>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
    <Style.Triggers>
      <DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=FontSize, Mode=OneWay, Converter={StaticResource IsGreaterThanConverter}, ConverterParameter=18}">
        <Setter Property="TextOptions.TextFormattingMode" Value="Ideal" />
      </DataTrigger>
    </Style.Triggers>
  </Style>
  <Style x:Key="{x:Type controls:Submenu}" TargetType="{x:Type controls:Submenu}">
    <Setter Property="Background" Value="{StaticResource BackgroundBrush}" />
    <Setter Property="BorderBrush" Value="{StaticResource LowlightBrush}" />
    <Setter Property="BorderThickness" Value="{Binding RelativeSource={RelativeSource Self}, Path=(params:General.DefaultThickness), Mode=OneWay}" />
    <Setter Property="params:MenuBase.SubmenuBackground" Value="{Binding RelativeSource={RelativeSource Self}, Path=Background, Mode=OneWay}" />
    <Setter Property="params:MenuBase.SubmenuBorderBrush" Value="{Binding RelativeSource={RelativeSource Self}, Path=BorderBrush, Mode=OneWay}" />
    <Setter Property="params:MenuBase.SubmenuBorderThickness" Value="{Binding RelativeSource={RelativeSource Self}, Path=BorderThickness, Mode=OneWay}" />
    <Setter Property="Foreground" Value="{StaticResource ForegroundBrush}" />
    <Setter Property="FontSize" Value="{Binding RelativeSource={RelativeSource Self}, Path=(params:General.ContentFontSize), Mode=OneWay}" />
    <Setter Property="FontStretch" Value="Medium" />
    <Setter Property="FontStyle" Value="Normal" />
    <Setter Property="FontWeight" Value="Normal" />
    <Setter Property="TextOptions.TextFormattingMode" Value="Display" />
    <Setter Property="TextOptions.TextRenderingMode" Value="ClearType" />
    <Setter Property="RenderOptions.ClearTypeHint" Value="Enabled" />
    <Setter Property="params:General.ShadowBrush" Value="{StaticResource ForegroundBrush}" />
    <Setter Property="Grid.IsSharedSizeScope" Value="True" />
    <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto" />
    <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto" />
    <Setter Property="ScrollViewer.PanningMode" Value="VerticalOnly" />
    <Setter Property="HorizontalContentAlignment" Value="Stretch" />
    <Setter Property="VerticalContentAlignment" Value="Stretch" />
    <Setter Property="Padding" Value="{Binding RelativeSource={RelativeSource Self}, Path=(params:General.BoldPadding), Mode=OneWay}" />
    <Setter Property="SnapsToDevicePixels" Value="True" />
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type controls:Submenu}">
          <Border x:Name="LayoutRoot" Tag="{DynamicResource {x:Static SystemParameters.DropShadowKey}}" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" TextBlock.Foreground="{TemplateBinding Foreground}" TextBlock.FontSize="{TemplateBinding FontSize}" TextBlock.FontStretch="{TemplateBinding FontStretch}" TextBlock.FontStyle="{TemplateBinding FontStyle}" TextBlock.FontWeight="{TemplateBinding FontWeight}" TextOptions.TextFormattingMode="{TemplateBinding TextOptions.TextFormattingMode}" TextOptions.TextRenderingMode="{TemplateBinding TextOptions.TextRenderingMode}" RenderOptions.ClearTypeHint="{TemplateBinding RenderOptions.ClearTypeHint}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">
            <ItemsPresenter KeyboardNavigation.DirectionalNavigation="Cycle" />
          </Border>
          <ControlTemplate.Triggers>
            <DataTrigger Binding="{Binding ElementName=LayoutRoot, Path=Tag}" Value="True">
              <Setter TargetName="LayoutRoot" Property="Effect">
                <Setter.Value>
                  <DropShadowEffect Color="{Binding RelativeSource={RelativeSource AncestorType={x:Type controls:Submenu}}, Path=(params:General.ShadowBrush).(SolidColorBrush.Color)}" BlurRadius="4" ShadowDepth="2" Direction="315" Opacity="0.3" />
                </Setter.Value>
              </Setter>
              <Setter TargetName="LayoutRoot" Property="Background" Value="{StaticResource TransparentBrush}" />
              <Setter TargetName="LayoutRoot" Property="Padding" Value="0,0,6,6" />
            </DataTrigger>
          </ControlTemplate.Triggers>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
    <Style.Triggers>
      <DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=FontSize, Mode=OneWay, Converter={StaticResource IsGreaterThanConverter}, ConverterParameter=18}">
        <Setter Property="TextOptions.TextFormattingMode" Value="Ideal" />
      </DataTrigger>
    </Style.Triggers>
  </Style>
  <Style TargetType="{x:Type ContextMenu}">
    <Setter Property="Background" Value="{StaticResource BackgroundBrush}" />
    <Setter Property="BorderBrush" Value="{StaticResource LowlightBrush}" />
    <Setter Property="BorderThickness" Value="{Binding RelativeSource={RelativeSource Self}, Path=(params:General.DefaultThickness), Mode=OneWay}" />
    <Setter Property="params:MenuBase.SubmenuBackground" Value="{Binding RelativeSource={RelativeSource Self}, Path=Background, Mode=OneWay}" />
    <Setter Property="params:MenuBase.SubmenuBorderBrush" Value="{Binding RelativeSource={RelativeSource Self}, Path=BorderBrush, Mode=OneWay}" />
    <Setter Property="params:MenuBase.SubmenuBorderThickness" Value="{Binding RelativeSource={RelativeSource Self}, Path=BorderThickness, Mode=OneWay}" />
    <Setter Property="Foreground" Value="{StaticResource ForegroundBrush}" />
    <Setter Property="FontSize" Value="{Binding RelativeSource={RelativeSource Self}, Path=(params:General.ContentFontSize), Mode=OneWay}" />
    <Setter Property="FontStretch" Value="Medium" />
    <Setter Property="FontStyle" Value="Normal" />
    <Setter Property="FontWeight" Value="Normal" />
    <Setter Property="TextOptions.TextFormattingMode" Value="Display" />
    <Setter Property="TextOptions.TextRenderingMode" Value="ClearType" />
    <Setter Property="RenderOptions.ClearTypeHint" Value="Enabled" />
    <Setter Property="HasDropShadow" Value="{DynamicResource {x:Static SystemParameters.DropShadowKey}}" />
    <Setter Property="params:General.ShadowBrush" Value="{StaticResource ForegroundBrush}" />
    <Setter Property="Focusable" Value="False" />
    <Setter Property="FocusVisualStyle" Value="{x:Null}" />
    <Setter Property="Grid.IsSharedSizeScope" Value="True" />
    <Setter Property="HorizontalContentAlignment" Value="Stretch" />
    <Setter Property="VerticalContentAlignment" Value="Stretch" />
    <Setter Property="Padding" Value="{Binding RelativeSource={RelativeSource Self}, Path=(params:General.BoldPadding), Mode=OneWay}" />
    <!-- Temporary removed to fix bugs 1144, 1174, 1216 -->
    <!--<Setter Property="OverridesDefaultStyle" Value="True"/>-->
    <Setter Property="SnapsToDevicePixels" Value="True" />
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type ContextMenu}">
          <Border x:Name="LayoutRoot">
            <Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" TextBlock.Foreground="{TemplateBinding Foreground}" TextBlock.FontFamily="{TemplateBinding FontFamily}" TextBlock.FontSize="{TemplateBinding FontSize}" TextBlock.FontStretch="{TemplateBinding FontStretch}" TextBlock.FontStyle="{TemplateBinding FontStyle}" TextBlock.FontWeight="{TemplateBinding FontWeight}" TextOptions.TextFormattingMode="{TemplateBinding TextOptions.TextFormattingMode}" TextOptions.TextRenderingMode="{TemplateBinding TextOptions.TextRenderingMode}" RenderOptions.ClearTypeHint="{TemplateBinding RenderOptions.ClearTypeHint}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">
              <ItemsPresenter KeyboardNavigation.DirectionalNavigation="Cycle" />
            </Border>
          </Border>
          <ControlTemplate.Triggers>
            <Trigger Property="HasDropShadow" Value="True">
              <Setter TargetName="LayoutRoot" Property="Effect">
                <Setter.Value>
                  <DropShadowEffect Color="{Binding RelativeSource={RelativeSource AncestorType={x:Type ContextMenu}}, Path=(params:General.ShadowBrush).(SolidColorBrush.Color)}" BlurRadius="4" ShadowDepth="2" Direction="315" Opacity="0.3" />
                </Setter.Value>
              </Setter>
              <Setter TargetName="LayoutRoot" Property="Background" Value="{StaticResource TransparentBrush}" />
              <Setter TargetName="LayoutRoot" Property="Padding" Value="0,0,6,6" />
            </Trigger>
          </ControlTemplate.Triggers>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
    <Style.Triggers>
      <DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=FontSize, Mode=OneWay, Converter={StaticResource IsGreaterThanConverter}, ConverterParameter=18}">
        <Setter Property="TextOptions.TextFormattingMode" Value="Ideal" />
      </DataTrigger>
    </Style.Triggers>
  </Style>
  <Style x:Key="TextBoxesBaseStyle" TargetType="{x:Type Control}">
    <Setter Property="Background" Value="{StaticResource BackgroundBrush}" />
    <Setter Property="BorderBrush" Value="{StaticResource MiddleLightBrush}" />
    <Setter Property="BorderThickness" Value="{Binding RelativeSource={RelativeSource Self}, Path=(params:General.SemiBoldThickness), Mode=OneWay}" />
    <Setter Property="Foreground" Value="{StaticResource ForegroundBrush}" />
    <Setter Property="FontSize" Value="{Binding RelativeSource={RelativeSource Self}, Path=(params:General.TextFontSize), Mode=OneWay}" />
    <Setter Property="FontStretch" Value="Medium" />
    <Setter Property="FontStyle" Value="Normal" />
    <Setter Property="FontWeight" Value="Normal" />
    <Setter Property="TextOptions.TextFormattingMode" Value="Display" />
    <Setter Property="TextOptions.TextRenderingMode" Value="ClearType" />
    <Setter Property="RenderOptions.ClearTypeHint" Value="Enabled" />
    <Setter Property="FocusVisualStyle" Value="{x:Null}" />
    <Setter Property="ScrollViewer.PanningMode" Value="VerticalFirst" />
    <Setter Property="Stylus.IsFlicksEnabled" Value="False" />
    <Setter Property="HorizontalContentAlignment" Value="Left" />
    <Setter Property="VerticalContentAlignment" Value="Center" />
    <Setter Property="Padding" Value="{Binding RelativeSource={RelativeSource Self}, Path=(params:General.DefaultPadding), Mode=OneWay}" />
    <Setter Property="ContextMenu">
      <Setter.Value>
        <ContextMenu Style="{StaticResource {x:Type ContextMenu}}">
          <MenuItem Header="Cut" Command="ApplicationCommands.Cut" />
          <MenuItem Header="Copy" Command="ApplicationCommands.Copy" />
          <MenuItem Header="Paste" Command="ApplicationCommands.Paste" />
        </ContextMenu>
      </Setter.Value>
    </Setter>
    <Setter Property="SnapsToDevicePixels" Value="True" />
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type Control}">
          <Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">
            <ScrollViewer x:Name="PART_ContentHost" Background="{StaticResource TransparentBrush}" Foreground="{TemplateBinding Foreground}" FontSize="{TemplateBinding FontSize}" FontStretch="{TemplateBinding FontStretch}" FontStyle="{TemplateBinding FontStyle}" FontWeight="{TemplateBinding FontWeight}" TextOptions.TextFormattingMode="{TemplateBinding TextOptions.TextFormattingMode}" TextOptions.TextRenderingMode="{TemplateBinding TextOptions.TextRenderingMode}" RenderOptions.ClearTypeHint="{TemplateBinding RenderOptions.ClearTypeHint}" Margin="{TemplateBinding Padding}" />
          </Border>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
    <Style.Triggers>
      <DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=FontSize, Mode=OneWay, Converter={StaticResource IsGreaterThanConverter}, ConverterParameter=18}">
        <Setter Property="TextOptions.TextFormattingMode" Value="Ideal" />
      </DataTrigger>
      <Trigger Property="IsMouseOver" Value="True">
        <Setter Property="BorderBrush" Value="{StaticResource AccentBrush}" />
        <Setter Property="Foreground" Value="{StaticResource ForegroundBrush}" />
      </Trigger>
      <Trigger Property="IsEnabled" Value="False">
        <Setter Property="BorderBrush" Value="{StaticResource DisabledBrush}" />
        <Setter Property="Foreground" Value="{StaticResource DisabledBrush}" />
      </Trigger>
    </Style.Triggers>
  </Style>
  <Style x:Key="TextBoxBaseStyle" TargetType="{x:Type TextBoxBase}" BasedOn="{StaticResource TextBoxesBaseStyle}">
    <Setter Property="CaretBrush" Value="{StaticResource ForegroundBrush}" />
    <Setter Property="SelectionBrush" Value="{StaticResource MiddleLightBrush}" />
    <Style.Triggers>
      <MultiTrigger>
        <MultiTrigger.Conditions>
          <Condition Property="IsKeyboardFocusWithin" Value="True" />
          <Condition Property="IsReadOnly" Value="False" />
        </MultiTrigger.Conditions>
        <MultiTrigger.Setters>
          <Setter Property="BorderBrush" Value="{StaticResource AccentBrush}" />
          <Setter Property="Foreground" Value="{StaticResource ForegroundBrush}" />
        </MultiTrigger.Setters>
      </MultiTrigger>
    </Style.Triggers>
  </Style>
  <Style TargetType="{x:Type TextBox}" BasedOn="{StaticResource TextBoxBaseStyle}">
    <!-- Temporary removed to fix bugs 1144, 1174, 1216 -->
    <!--<Setter Property="OverridesDefaultStyle" Value="True"/>-->
  </Style>
  <Style TargetType="{x:Type RichTextBox}" BasedOn="{StaticResource TextBoxBaseStyle}">
    <Style.Resources>
      <Style TargetType="{x:Type FlowDocument}">
        <Setter Property="OverridesDefaultStyle" Value="True" />
      </Style>
    </Style.Resources>
    <!-- Temporary removed to fix bugs 1144, 1174, 1216 -->
    <!--<Setter Property="OverridesDefaultStyle" Value="True"/>-->
  </Style>
  <Style TargetType="{x:Type PasswordBox}" BasedOn="{StaticResource TextBoxesBaseStyle}">
    <Setter Property="PasswordChar" Value="●" />
    <Setter Property="CaretBrush" Value="{StaticResource ForegroundBrush}" />
    <Setter Property="SelectionBrush" Value="{StaticResource MiddleLightBrush}" />
    <!-- Temporary removed to fix bugs 1144, 1174, 1216 -->
    <!--<Setter Property="OverridesDefaultStyle" Value="True"/>-->
    <Style.Triggers>
      <Trigger Property="IsKeyboardFocusWithin" Value="True">
        <Setter Property="BorderBrush" Value="{StaticResource AccentBrush}" />
        <Setter Property="Foreground" Value="{StaticResource ForegroundBrush}" />
      </Trigger>
    </Style.Triggers>
  </Style>
  <Style x:Key="SelectorsItemsBaseStyle" TargetType="{x:Type ListBoxItem}">
    <Setter Property="Background" Value="{StaticResource TransparentBrush}" />
    <Setter Property="BorderBrush" Value="{StaticResource MiddleLightBrush}" />
    <Setter Property="BorderThickness" Value="0" />
    <Setter Property="Foreground" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type Selector}}, Path=Foreground, Mode=OneWay}" />
    <Setter Property="FontFamily" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type Selector}}, Path=FontFamily, Mode=OneWay}" />
    <Setter Property="FontSize" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type Selector}}, Path=FontSize, Mode=OneWay}" />
    <Setter Property="FontStretch" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type Selector}}, Path=FontStretch, Mode=OneWay}" />
    <Setter Property="FontStyle" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type Selector}}, Path=FontStyle, Mode=OneWay}" />
    <Setter Property="FontWeight" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type Selector}}, Path=FontWeight, Mode=OneWay}" />
    <Setter Property="TextOptions.TextFormattingMode" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type Selector}}, Path=(TextOptions.TextFormattingMode), Mode=OneWay}" />
    <Setter Property="TextOptions.TextRenderingMode" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type Selector}}, Path=(TextOptions.TextRenderingMode), Mode=OneWay}" />
    <Setter Property="RenderOptions.ClearTypeHint" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type Selector}}, Path=(RenderOptions.ClearTypeHint), Mode=OneWay}" />
    <Setter Property="Focusable" Value="True" />
    <Setter Property="FocusVisualStyle" Value="{StaticResource FocusVisualStyle}" />
    <Setter Property="HorizontalContentAlignment" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type Selector}}, Path=HorizontalContentAlignment, Mode=OneWay}" />
    <Setter Property="VerticalContentAlignment" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type Selector}}, Path=VerticalContentAlignment, Mode=OneWay}" />
    <Setter Property="Padding" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type Selector}}, Path=Padding, Mode=OneWay}" />
    <Setter Property="SnapsToDevicePixels" Value="True" />
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type ListBoxItem}">
          <Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" TextBlock.Foreground="{TemplateBinding Foreground}" TextBlock.FontSize="{TemplateBinding FontSize}" TextBlock.FontStretch="{TemplateBinding FontStretch}" TextBlock.FontStyle="{TemplateBinding FontStyle}" TextBlock.FontWeight="{TemplateBinding FontWeight}" TextOptions.TextFormattingMode="{TemplateBinding TextOptions.TextFormattingMode}" TextOptions.TextRenderingMode="{TemplateBinding TextOptions.TextRenderingMode}" RenderOptions.ClearTypeHint="{TemplateBinding RenderOptions.ClearTypeHint}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">
            <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Margin="{TemplateBinding Padding}" />
          </Border>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
    <Style.Triggers>
      <Trigger Property="IsEnabled" Value="False">
        <Setter Property="Foreground" Value="{StaticResource DisabledBrush}" />
      </Trigger>
    </Style.Triggers>
  </Style>
  <Style TargetType="{x:Type ListBoxItem}" BasedOn="{StaticResource SelectorsItemsBaseStyle}">
    <!-- Temporary removed to fix bugs 1144, 1174, 1216 -->
    <!--<Setter Property="OverridesDefaultStyle" Value="True"/>-->
    <Style.Triggers>
      <MultiTrigger>
        <MultiTrigger.Conditions>
          <Condition Property="IsEnabled" Value="True" />
          <Condition Property="IsSelected" Value="True" />
        </MultiTrigger.Conditions>
        <MultiTrigger.Setters>
          <Setter Property="Background" Value="{StaticResource AccentBrush}" />
          <Setter Property="Foreground" Value="{StaticResource ContrastBrush}" />
        </MultiTrigger.Setters>
      </MultiTrigger>
      <MultiTrigger>
        <MultiTrigger.Conditions>
          <Condition Property="IsEnabled" Value="False" />
          <Condition Property="IsSelected" Value="True" />
        </MultiTrigger.Conditions>
        <MultiTrigger.Setters>
          <Setter Property="Background" Value="{StaticResource DisabledBrush}" />
          <Setter Property="Foreground" Value="{StaticResource ContrastBrush}" />
        </MultiTrigger.Setters>
      </MultiTrigger>
    </Style.Triggers>
  </Style>
  <Style TargetType="{x:Type ComboBoxItem}" BasedOn="{StaticResource SelectorsItemsBaseStyle}">
    <Setter Property="Background" Value="{StaticResource BackgroundBrush}" />
    <!-- Temporary removed to fix bugs 1144, 1174, 1216 -->
    <!--<Setter Property="OverridesDefaultStyle" Value="True"/>-->
    <Style.Triggers>
      <MultiTrigger>
        <MultiTrigger.Conditions>
          <Condition Property="IsEnabled" Value="True" />
          <Condition Property="IsHighlighted" Value="True" />
        </MultiTrigger.Conditions>
        <Setter Property="Background" Value="{StaticResource AccentBrush}" />
        <Setter Property="Foreground" Value="{StaticResource ContrastBrush}" />
      </MultiTrigger>
      <MultiTrigger>
        <MultiTrigger.Conditions>
          <Condition Property="IsEnabled" Value="False" />
          <Condition Property="IsHighlighted" Value="True" />
        </MultiTrigger.Conditions>
        <Setter Property="Background" Value="{StaticResource DisabledBrush}" />
        <Setter Property="Foreground" Value="{StaticResource ContrastBrush}" />
      </MultiTrigger>
    </Style.Triggers>
  </Style>
  <Style TargetType="{x:Type ListBox}">
    <Setter Property="Background" Value="{StaticResource BackgroundBrush}" />
    <Setter Property="BorderBrush" Value="{StaticResource MiddleLightBrush}" />
    <Setter Property="BorderThickness" Value="0" />
    <Setter Property="Foreground" Value="{StaticResource ForegroundBrush}" />
    <Setter Property="FontSize" Value="{Binding RelativeSource={RelativeSource Self}, Path=(params:General.ContentFontSize), Mode=OneWay}" />
    <Setter Property="FontStretch" Value="Medium" />
    <Setter Property="FontStyle" Value="Normal" />
    <Setter Property="FontWeight" Value="Normal" />
    <Setter Property="TextOptions.TextFormattingMode" Value="Display" />
    <Setter Property="TextOptions.TextRenderingMode" Value="ClearType" />
    <Setter Property="RenderOptions.ClearTypeHint" Value="Enabled" />
    <Setter Property="Focusable" Value="True" />
    <Setter Property="FocusVisualStyle" Value="{x:Null}" />
    <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto" />
    <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto" />
    <Setter Property="ScrollViewer.CanContentScroll" Value="true" />
    <Setter Property="ScrollViewer.PanningMode" Value="Both" />
    <Setter Property="Stylus.IsFlicksEnabled" Value="False" />
    <Setter Property="HorizontalContentAlignment" Value="Left" />
    <Setter Property="VerticalContentAlignment" Value="Center" />
    <Setter Property="Padding" Value="{Binding RelativeSource={RelativeSource Self}, Path=(params:General.BoldPadding), Mode=OneWay}" />
    <!-- Temporary removed to fix bugs 1144, 1174, 1216 -->
    <!--<Setter Property="OverridesDefaultStyle" Value="True"/>-->
    <Setter Property="SnapsToDevicePixels" Value="True" />
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type ListBox}">
          <Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">
            <ScrollViewer Background="{x:Null}" Foreground="{TemplateBinding Foreground}" FontSize="{TemplateBinding FontSize}" FontStretch="{TemplateBinding FontStretch}" FontStyle="{TemplateBinding FontStyle}" FontWeight="{TemplateBinding FontWeight}" TextOptions.TextFormattingMode="{TemplateBinding TextOptions.TextFormattingMode}" TextOptions.TextRenderingMode="{TemplateBinding TextOptions.TextRenderingMode}" RenderOptions.ClearTypeHint="{TemplateBinding RenderOptions.ClearTypeHint}" Focusable="False">
              <ItemsPresenter />
            </ScrollViewer>
          </Border>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
    <Style.Triggers>
      <DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=FontSize, Mode=OneWay, Converter={StaticResource IsGreaterThanConverter}, ConverterParameter=18}">
        <Setter Property="TextOptions.TextFormattingMode" Value="Ideal" />
      </DataTrigger>
      <Trigger Property="IsEnabled" Value="False">
        <Setter Property="BorderBrush" Value="{StaticResource DisabledBrush}" />
        <Setter Property="Foreground" Value="{StaticResource DisabledBrush}" />
      </Trigger>
      <Trigger Property="IsGrouping" Value="True">
        <Setter Property="ScrollViewer.CanContentScroll" Value="False" />
      </Trigger>
    </Style.Triggers>
  </Style>
  <Style x:Key="ComboBoxToggleButton" TargetType="{x:Type ToggleButton}">
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type ToggleButton}">
          <Border Background="{StaticResource TransparentBrush}" BorderBrush="{StaticResource TransparentBrush}" BorderThickness="0" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">
            <Polygon x:Name="ArrowGlyph" Fill="{StaticResource MiddleLightBrush}" StrokeThickness="0" Stretch="Uniform" Margin="{Binding RelativeSource={RelativeSource AncestorType={x:Type ComboBox}}, Path=(params:ComboBox.ArrowMargin), Mode=OneWay}" HorizontalAlignment="Right" VerticalAlignment="Center" Width="{Binding RelativeSource={RelativeSource AncestorType={x:Type ComboBox}}, Path=(params:ComboBox.ArrowSize), Mode=OneWay}" Height="{Binding RelativeSource={RelativeSource AncestorType={x:Type ComboBox}}, Path=(params:ComboBox.ArrowSize), Mode=OneWay}">
              <Polygon.Points>
                <PointCollection>
                  <Point X="0" Y="0" />
                  <Point X="3" Y="4" />
                  <Point X="6" Y="0" />
                </PointCollection>
              </Polygon.Points>
            </Polygon>
          </Border>
          <ControlTemplate.Triggers>
            <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type ComboBox}}, Path=IsDropDownOpen, Mode=OneWay}">
              <Setter TargetName="ArrowGlyph" Property="Fill" Value="{StaticResource AccentBrush}" />
            </DataTrigger>
          </ControlTemplate.Triggers>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>
  <Style x:Key="ComboBoxTextBox" TargetType="{x:Type TextBox}">
    <Setter Property="TextOptions.TextFormattingMode" Value="Display" />
    <Setter Property="TextOptions.TextRenderingMode" Value="ClearType" />
    <Setter Property="RenderOptions.ClearTypeHint" Value="Enabled" />
    <Setter Property="CaretBrush" Value="{StaticResource ForegroundBrush}" />
    <Setter Property="SelectionBrush" Value="{StaticResource MiddleLightBrush}" />
    <Setter Property="FocusVisualStyle" Value="{x:Null}" />
    <Setter Property="ScrollViewer.PanningMode" Value="VerticalFirst" />
    <Setter Property="Stylus.IsFlicksEnabled" Value="False" />
    <!-- Temporary removed to fix bugs 1144, 1174, 1216 -->
    <!--<Setter Property="OverridesDefaultStyle" Value="True"/>-->
    <Setter Property="SnapsToDevicePixels" Value="True" />
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type TextBox}">
          <Border Background="{StaticResource TransparentBrush}" BorderBrush="{StaticResource TransparentBrush}" BorderThickness="0" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">
            <ScrollViewer x:Name="PART_ContentHost" Background="{x:Null}" Foreground="{TemplateBinding Foreground}" FontFamily="{TemplateBinding FontFamily}" FontSize="{TemplateBinding FontSize}" FontStretch="{TemplateBinding FontStretch}" FontStyle="{TemplateBinding FontStyle}" FontWeight="{TemplateBinding FontWeight}" TextOptions.TextFormattingMode="{TemplateBinding TextOptions.TextFormattingMode}" TextOptions.TextRenderingMode="{TemplateBinding TextOptions.TextRenderingMode}" RenderOptions.ClearTypeHint="{TemplateBinding RenderOptions.ClearTypeHint}" Margin="{TemplateBinding Padding}" />
          </Border>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
    <Style.Triggers>
      <DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=FontSize, Mode=OneWay, Converter={StaticResource IsGreaterThanConverter}, ConverterParameter=18}">
        <Setter Property="TextOptions.TextFormattingMode" Value="Ideal" />
      </DataTrigger>
    </Style.Triggers>
  </Style>
  <Style TargetType="{x:Type ComboBox}">
    <Setter Property="Background" Value="{StaticResource BackgroundBrush}" />
    <Setter Property="BorderBrush" Value="{StaticResource MiddleLightBrush}" />
    <Setter Property="BorderThickness" Value="{Binding RelativeSource={RelativeSource Self}, Path=(params:General.DefaultThickness), Mode=OneWay}" />
    <Setter Property="Foreground" Value="{StaticResource ForegroundBrush}" />
    <Setter Property="FontSize" Value="{Binding RelativeSource={RelativeSource Self}, Path=(params:General.ContentFontSize), Mode=OneWay}" />
    <Setter Property="FontStretch" Value="Medium" />
    <Setter Property="FontStyle" Value="Normal" />
    <Setter Property="FontWeight" Value="Normal" />
    <Setter Property="TextOptions.TextFormattingMode" Value="Display" />
    <Setter Property="TextOptions.TextRenderingMode" Value="ClearType" />
    <Setter Property="RenderOptions.ClearTypeHint" Value="Enabled" />
    <Setter Property="params:General.ShadowBrush" Value="{StaticResource ForegroundBrush}" />
    <Setter Property="Focusable" Value="True" />
    <Setter Property="FocusVisualStyle" Value="{StaticResource FocusVisualStyle}" />
    <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto" />
    <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto" />
    <Setter Property="ScrollViewer.CanContentScroll" Value="True" />
    <Setter Property="ScrollViewer.PanningMode" Value="Both" />
    <Setter Property="Stylus.IsFlicksEnabled" Value="False" />
    <Setter Property="HorizontalContentAlignment" Value="Left" />
    <Setter Property="VerticalContentAlignment" Value="Center" />
    <Setter Property="Padding" Value="{Binding RelativeSource={RelativeSource Self}, Path=(params:General.BoldPadding), Mode=OneWay}" />
    <!-- Temporary removed to fix bugs 1144, 1174, 1216 -->
    <!--<Setter Property="OverridesDefaultStyle" Value="True"/>-->
    <Setter Property="SnapsToDevicePixels" Value="True" />
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type ComboBox}">
          <Decorator x:Name="LayoutRoot">
            <Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">
              <Grid>
                <Grid.ColumnDefinitions>
                  <ColumnDefinition Width="*" />
                  <ColumnDefinition Width="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(params:ComboBox.ButtonSize), Converter={StaticResource DoubleToGridLengthConverter}}" />
                </Grid.ColumnDefinitions>
                <Popup x:Name="PART_Popup" Grid.Column="0" Grid.ColumnSpan="2" AllowsTransparency="True" IsOpen="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=IsDropDownOpen, Mode=TwoWay}" PlacementTarget="{Binding ElementName=LayoutRoot}" Placement="Custom" VerticalOffset="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=BorderThickness, Converter={StaticResource ThicknessToDoubleConverter}, ConverterParameter='Bottom'}" CustomPopupPlacementCallback="{x:Static params:DropDown.PopupPlacementCallback}" PopupAnimation="{DynamicResource {x:Static SystemParameters.ComboBoxPopupAnimationKey}}" Tag="{DynamicResource {x:Static SystemParameters.ComboBoxAnimationKey}}">
                  <Popup.Resources>
                    <Style TargetType="{x:Type ScrollBar}" BasedOn="{StaticResource {x:Type ScrollBar}}">
                      <Style.Triggers>
                        <Trigger Property="Orientation" Value="Vertical">
                          <Setter Property="BorderThickness" Value="0" />
                        </Trigger>
                      </Style.Triggers>
                    </Style>
                  </Popup.Resources>
                  <Border x:Name="PopupRoot" Tag="{DynamicResource {x:Static SystemParameters.DropShadowKey}}">
                    <ScrollViewer x:Name="DropDownScrollViewer" Background="{StaticResource BackgroundBrush}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Foreground="{TemplateBinding Foreground}" FontSize="{TemplateBinding FontSize}" FontStretch="{TemplateBinding FontStretch}" FontStyle="{TemplateBinding FontStyle}" FontWeight="{TemplateBinding FontWeight}" TextOptions.TextFormattingMode="{TemplateBinding TextOptions.TextFormattingMode}" TextOptions.TextRenderingMode="{TemplateBinding TextOptions.TextRenderingMode}" RenderOptions.ClearTypeHint="{TemplateBinding RenderOptions.ClearTypeHint}" MinWidth="{Binding ElementName=LayoutRoot, Path=ActualWidth}" MaxHeight="{TemplateBinding MaxDropDownHeight}">
                      <ItemsPresenter KeyboardNavigation.DirectionalNavigation="Contained" />
                    </ScrollViewer>
                  </Border>
                </Popup>
                <ToggleButton x:Name="Button" Grid.Column="0" Grid.ColumnSpan="2" IsChecked="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=IsDropDownOpen, Mode=TwoWay}" Style="{StaticResource ComboBoxToggleButton}" />
                <ContentPresenter x:Name="ContentPresenter" Grid.Column="0" Content="{TemplateBinding SelectionBoxItem}" ContentStringFormat="{TemplateBinding SelectionBoxItemStringFormat}" ContentTemplate="{TemplateBinding SelectionBoxItemTemplate}" ContentTemplateSelector="{TemplateBinding ItemTemplateSelector}" TextBlock.Foreground="{TemplateBinding Foreground}" TextBlock.FontSize="{TemplateBinding FontSize}" TextBlock.FontStretch="{TemplateBinding FontStretch}" TextBlock.FontStyle="{TemplateBinding FontStyle}" TextBlock.FontWeight="{TemplateBinding FontWeight}" TextOptions.TextFormattingMode="{TemplateBinding TextOptions.TextFormattingMode}" TextOptions.TextRenderingMode="{TemplateBinding TextOptions.TextRenderingMode}" RenderOptions.ClearTypeHint="{TemplateBinding RenderOptions.ClearTypeHint}" IsHitTestVisible="False" Margin="{TemplateBinding Padding}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Visibility="Visible" />
                <Grid x:Name="TextBoxLayout" Grid.Column="0" Background="{StaticResource BackgroundBrush}" Visibility="Collapsed">
                  <TextBox x:Name="PART_EditableTextBox" Foreground="{TemplateBinding Foreground}" FontFamily="{TemplateBinding FontFamily}" FontSize="{TemplateBinding FontSize}" FontStretch="{TemplateBinding FontStretch}" FontStyle="{TemplateBinding FontStyle}" FontWeight="{TemplateBinding FontWeight}" IsReadOnly="{TemplateBinding IsReadOnly}" Margin="{TemplateBinding Padding}" Style="{StaticResource ComboBoxTextBox}" />
                </Grid>
              </Grid>
            </Border>
          </Decorator>
          <ControlTemplate.Triggers>
            <Trigger Property="IsEditable" Value="True">
              <Setter TargetName="Button" Property="Grid.Column" Value="1" />
              <Setter TargetName="Button" Property="Grid.ColumnSpan" Value="1" />
              <Setter TargetName="ContentPresenter" Property="Visibility" Value="Collapsed" />
              <Setter TargetName="TextBoxLayout" Property="Visibility" Value="Visible" />
            </Trigger>
            <Trigger SourceName="PART_Popup" Property="Tag" Value="False">
              <Setter TargetName="PART_Popup" Property="PopupAnimation" Value="None" />
            </Trigger>
            <Trigger Property="IsDropDownOpen" Value="True">
              <Setter TargetName="PART_Popup" Property="params:DropDown.IsOpen" Value="True" />
            </Trigger>
            <MultiTrigger>
              <MultiTrigger.Conditions>
                <Condition SourceName="PART_Popup" Property="params:DropDown.IsDefaultHorizontalPosition" Value="True" />
                <Condition SourceName="PART_Popup" Property="params:DropDown.IsDefaultVerticalPosition" Value="True" />
              </MultiTrigger.Conditions>
              <MultiTrigger.Setters>
                <Setter TargetName="DropDownScrollViewer" Property="BorderThickness" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=BorderThickness, Mode=OneWay, Converter={StaticResource ThicknessConverter}, ConverterParameter='Left, Right, Bottom'}" />
              </MultiTrigger.Setters>
            </MultiTrigger>
            <MultiTrigger>
              <MultiTrigger.Conditions>
                <Condition SourceName="PART_Popup" Property="params:DropDown.IsDefaultHorizontalPosition" Value="True" />
                <Condition SourceName="PART_Popup" Property="params:DropDown.IsDefaultVerticalPosition" Value="False" />
              </MultiTrigger.Conditions>
              <MultiTrigger.Setters>
                <Setter TargetName="DropDownScrollViewer" Property="BorderThickness" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=BorderThickness, Mode=OneWay, Converter={StaticResource ThicknessConverter}, ConverterParameter='Left, Top, Right'}" />
              </MultiTrigger.Setters>
            </MultiTrigger>
            <MultiDataTrigger>
              <MultiDataTrigger.Conditions>
                <Condition Binding="{Binding ElementName=PopupRoot, Path=Tag}" Value="True" />
                <Condition Binding="{Binding ElementName=PART_Popup, Path=(params:DropDown.IsDefaultVerticalPosition)}" Value="True" />
              </MultiDataTrigger.Conditions>
              <MultiDataTrigger.Setters>
                <Setter TargetName="PopupRoot" Property="Effect">
                  <Setter.Value>
                    <DropShadowEffect Color="{Binding RelativeSource={RelativeSource AncestorType={x:Type ComboBox}}, Path=(params:General.ShadowBrush).(SolidColorBrush.Color)}" BlurRadius="4" ShadowDepth="2" Direction="315" Opacity="0.3" />
                  </Setter.Value>
                </Setter>
                <Setter TargetName="PopupRoot" Property="Background" Value="{StaticResource TransparentBrush}" />
                <Setter TargetName="PopupRoot" Property="Padding" Value="0,0,6,6" />
              </MultiDataTrigger.Setters>
            </MultiDataTrigger>
            <MultiDataTrigger>
              <MultiDataTrigger.Conditions>
                <Condition Binding="{Binding ElementName=PopupRoot, Path=Tag}" Value="True" />
                <Condition Binding="{Binding ElementName=PART_Popup, Path=(params:DropDown.IsDefaultVerticalPosition)}" Value="False" />
              </MultiDataTrigger.Conditions>
              <MultiDataTrigger.Setters>
                <Setter TargetName="PopupRoot" Property="Effect">
                  <Setter.Value>
                    <DropShadowEffect Color="{Binding RelativeSource={RelativeSource AncestorType={x:Type ComboBox}}, Path=(params:General.ShadowBrush).(SolidColorBrush.Color)}" BlurRadius="4" ShadowDepth="0" Direction="45" Opacity="0.3" />
                  </Setter.Value>
                </Setter>
                <Setter TargetName="PopupRoot" Property="Background" Value="{StaticResource TransparentBrush}" />
                <Setter TargetName="PopupRoot" Property="Padding" Value="0,4,4,0" />
              </MultiDataTrigger.Setters>
            </MultiDataTrigger>
          </ControlTemplate.Triggers>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
    <Style.Triggers>
      <DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=FontSize, Mode=OneWay, Converter={StaticResource IsGreaterThanConverter}, ConverterParameter=18}">
        <Setter Property="TextOptions.TextFormattingMode" Value="Ideal" />
      </DataTrigger>
      <Trigger Property="IsEnabled" Value="False">
        <Setter Property="BorderBrush" Value="{StaticResource DisabledBrush}" />
        <Setter Property="Foreground" Value="{StaticResource DisabledBrush}" />
      </Trigger>
      <Trigger Property="IsGrouping" Value="True">
        <Setter Property="ScrollViewer.CanContentScroll" Value="False" />
      </Trigger>
      <Trigger Property="IsMouseOver" Value="True">
        <Setter Property="Background" Value="{StaticResource HighlightBrush}" />
      </Trigger>
      <Trigger Property="IsDropDownOpen" Value="True">
        <Setter Property="Background" Value="{StaticResource HighlightBrush}" />
      </Trigger>
    </Style.Triggers>
  </Style>
  <ControlTemplate x:Key="HorizontalProgressBarTemplate" TargetType="{x:Type controls:ProgressBar}">
    <Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" ClipToBounds="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">
      <Canvas x:Name="PART_Track">
        <Rectangle x:Name="PART_Indicator" Fill="{TemplateBinding Foreground}" StrokeThickness="0" Canvas.Left="0" Canvas.Top="0" Width="{Binding ElementName=PART_Track, Path=ActualWidth}" Height="{Binding ElementName=PART_Track, Path=ActualHeight}">
          <Rectangle.LayoutTransform>
            <ScaleTransform ScaleX="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Percent}" />
          </Rectangle.LayoutTransform>
        </Rectangle>
        <Canvas x:Name="PART_BusyBar" Canvas.Left="0" Canvas.Top="0" Visibility="Hidden">
          <Ellipse Fill="{TemplateBinding Foreground}" StrokeThickness="0" Canvas.Left="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(params:Progress.BusyElementSize), Converter={StaticResource NumberPositiveToNegativeConverter}}" Width="{TemplateBinding params:Progress.BusyElementSize}" Height="{TemplateBinding params:Progress.BusyElementSize}" />
          <Ellipse Fill="{TemplateBinding Foreground}" StrokeThickness="0" Canvas.Left="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(params:Progress.BusyElementSize), Converter={StaticResource NumberPositiveToNegativeConverter}}" Width="{TemplateBinding params:Progress.BusyElementSize}" Height="{TemplateBinding params:Progress.BusyElementSize}" />
          <Ellipse Fill="{TemplateBinding Foreground}" StrokeThickness="0" Canvas.Left="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(params:Progress.BusyElementSize), Converter={StaticResource NumberPositiveToNegativeConverter}}" Width="{TemplateBinding params:Progress.BusyElementSize}" Height="{TemplateBinding params:Progress.BusyElementSize}" />
          <Ellipse Fill="{TemplateBinding Foreground}" StrokeThickness="0" Canvas.Left="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(params:Progress.BusyElementSize), Converter={StaticResource NumberPositiveToNegativeConverter}}" Width="{TemplateBinding params:Progress.BusyElementSize}" Height="{TemplateBinding params:Progress.BusyElementSize}" />
          <Ellipse Fill="{TemplateBinding Foreground}" StrokeThickness="0" Canvas.Left="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(params:Progress.BusyElementSize), Converter={StaticResource NumberPositiveToNegativeConverter}}" Width="{TemplateBinding params:Progress.BusyElementSize}" Height="{TemplateBinding params:Progress.BusyElementSize}" />
        </Canvas>
      </Canvas>
    </Border>
    <ControlTemplate.Triggers>
      <MultiTrigger>
        <MultiTrigger.Conditions>
          <Condition Property="State" Value="Indeterminate" />
          <Condition Property="IsEnabled" Value="True" />
        </MultiTrigger.Conditions>
        <MultiTrigger.Setters>
          <Setter TargetName="PART_Indicator" Property="Canvas.Left" Value="{Binding ElementName=PART_Indicator, Path=ActualWidth, Converter={StaticResource NumberPositiveToNegativeConverter}}" />
          <Setter TargetName="PART_Indicator" Property="LayoutTransform">
            <Setter.Value>
              <ScaleTransform ScaleX="0.4" />
            </Setter.Value>
          </Setter>
        </MultiTrigger.Setters>
      </MultiTrigger>
      <MultiTrigger>
        <MultiTrigger.Conditions>
          <Condition Property="State" Value="Busy" />
          <Condition Property="IsEnabled" Value="True" />
        </MultiTrigger.Conditions>
        <MultiTrigger.Setters>
          <Setter TargetName="PART_Indicator" Property="Visibility" Value="Hidden" />
          <Setter TargetName="PART_BusyBar" Property="Visibility" Value="Visible" />
        </MultiTrigger.Setters>
      </MultiTrigger>
    </ControlTemplate.Triggers>
  </ControlTemplate>
  <ControlTemplate x:Key="VerticalProgressBarTemplate" TargetType="{x:Type controls:ProgressBar}">
    <Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" ClipToBounds="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">
      <Canvas x:Name="PART_Track" RenderTransformOrigin="0.5,0.5">
        <Canvas.RenderTransform>
          <ScaleTransform ScaleY="-1" />
        </Canvas.RenderTransform>
        <Rectangle x:Name="PART_Indicator" Fill="{TemplateBinding Foreground}" StrokeThickness="0" Canvas.Left="0" Canvas.Top="0" Width="{Binding ElementName=PART_Track, Path=ActualWidth}" Height="{Binding ElementName=PART_Track, Path=ActualHeight}">
          <Rectangle.LayoutTransform>
            <ScaleTransform ScaleY="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Percent}" />
          </Rectangle.LayoutTransform>
        </Rectangle>
        <Canvas x:Name="PART_BusyBar" Canvas.Left="0" Canvas.Top="0" Visibility="Hidden">
          <Ellipse Fill="{TemplateBinding Foreground}" StrokeThickness="0" Canvas.Top="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(params:Progress.BusyElementSize), Converter={StaticResource NumberPositiveToNegativeConverter}}" Width="{TemplateBinding params:Progress.BusyElementSize}" Height="{TemplateBinding params:Progress.BusyElementSize}" />
          <Ellipse Fill="{TemplateBinding Foreground}" StrokeThickness="0" Canvas.Top="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(params:Progress.BusyElementSize), Converter={StaticResource NumberPositiveToNegativeConverter}}" Width="{TemplateBinding params:Progress.BusyElementSize}" Height="{TemplateBinding params:Progress.BusyElementSize}" />
          <Ellipse Fill="{TemplateBinding Foreground}" StrokeThickness="0" Canvas.Top="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(params:Progress.BusyElementSize), Converter={StaticResource NumberPositiveToNegativeConverter}}" Width="{TemplateBinding params:Progress.BusyElementSize}" Height="{TemplateBinding params:Progress.BusyElementSize}" />
          <Ellipse Fill="{TemplateBinding Foreground}" StrokeThickness="0" Canvas.Top="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(params:Progress.BusyElementSize), Converter={StaticResource NumberPositiveToNegativeConverter}}" Width="{TemplateBinding params:Progress.BusyElementSize}" Height="{TemplateBinding params:Progress.BusyElementSize}" />
          <Ellipse Fill="{TemplateBinding Foreground}" StrokeThickness="0" Canvas.Top="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(params:Progress.BusyElementSize), Converter={StaticResource NumberPositiveToNegativeConverter}}" Width="{TemplateBinding params:Progress.BusyElementSize}" Height="{TemplateBinding params:Progress.BusyElementSize}" />
        </Canvas>
      </Canvas>
    </Border>
    <ControlTemplate.Triggers>
      <MultiTrigger>
        <MultiTrigger.Conditions>
          <Condition Property="State" Value="Indeterminate" />
          <Condition Property="IsEnabled" Value="True" />
        </MultiTrigger.Conditions>
        <MultiTrigger.Setters>
          <Setter TargetName="PART_Indicator" Property="Canvas.Top" Value="{Binding ElementName=PART_Indicator, Path=ActualHeight, Converter={StaticResource NumberPositiveToNegativeConverter}}" />
          <Setter TargetName="PART_Indicator" Property="LayoutTransform">
            <Setter.Value>
              <ScaleTransform ScaleY="0.4" />
            </Setter.Value>
          </Setter>
        </MultiTrigger.Setters>
      </MultiTrigger>
      <MultiTrigger>
        <MultiTrigger.Conditions>
          <Condition Property="State" Value="Busy" />
          <Condition Property="IsEnabled" Value="True" />
        </MultiTrigger.Conditions>
        <MultiTrigger.Setters>
          <Setter TargetName="PART_Indicator" Property="Visibility" Value="Hidden" />
          <Setter TargetName="PART_BusyBar" Property="Visibility" Value="Visible" />
        </MultiTrigger.Setters>
      </MultiTrigger>
    </ControlTemplate.Triggers>
  </ControlTemplate>
  <Style x:Key="{x:Type controls:ProgressBar}" TargetType="{x:Type controls:ProgressBar}">
    <Setter Property="Background" Value="{StaticResource HighlightBrush}" />
    <Setter Property="BorderBrush" Value="{StaticResource MiddleLightBrush}" />
    <Setter Property="BorderThickness" Value="0" />
    <Setter Property="Foreground" Value="{StaticResource AccentBrush}" />
    <Setter Property="FocusVisualStyle" Value="{x:Null}" />
    <Setter Property="Focusable" Value="False" />
    <Setter Property="SnapsToDevicePixels" Value="True" />
    <Style.Triggers>
      <Trigger Property="State" Value="Busy">
        <Setter Property="Background" Value="{x:Null}" />
      </Trigger>
      <Trigger Property="IsEnabled" Value="False">
        <Setter Property="Foreground" Value="{StaticResource DisabledBrush}" />
      </Trigger>
      <Trigger Property="Orientation" Value="Horizontal">
        <Setter Property="MinHeight" Value="2" />
        <Setter Property="Height" Value="4" />
        <Setter Property="MaxHeight" Value="8" />
        <Setter Property="MinWidth" Value="2" />
        <Setter Property="Template" Value="{StaticResource HorizontalProgressBarTemplate}" />
      </Trigger>
      <Trigger Property="Orientation" Value="Vertical">
        <Setter Property="MinHeight" Value="2" />
        <Setter Property="MinWidth" Value="2" />
        <Setter Property="Width" Value="4" />
        <Setter Property="MaxWidth" Value="8" />
        <Setter Property="Template" Value="{StaticResource VerticalProgressBarTemplate}" />
      </Trigger>
    </Style.Triggers>
  </Style>
  <Style x:Key="{x:Type controls:ProgressRing}" TargetType="{x:Type controls:ProgressRing}">
    <Setter Property="Background" Value="{StaticResource BackgroundBrush}" />
    <Setter Property="BorderBrush" Value="{StaticResource HighlightBrush}" />
    <Setter Property="BorderThickness" Value="3" />
    <Setter Property="Foreground" Value="{StaticResource AccentBrush}" />
    <Setter Property="FocusVisualStyle" Value="{x:Null}" />
    <Setter Property="Focusable" Value="False" />
    <Setter Property="MinWidth" Value="8px" />
    <Setter Property="MinHeight" Value="8px" />
    <Setter Property="SnapsToDevicePixels" Value="True" />
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type controls:ProgressRing}">
          <Border ClipToBounds="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">
            <Canvas x:Name="PART_Track" RenderTransformOrigin="0.5,0.5">
              <Canvas.RenderTransform>
                <RotateTransform Angle="90" />
              </Canvas.RenderTransform>
              <ed:Arc x:Name="BackgroundArc" Fill="{TemplateBinding Background}" Stroke="{TemplateBinding BorderBrush}" StrokeThickness="{Binding BorderThickness, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource ThicknessToDoubleConverter}}" StartAngle="0" EndAngle="360" Stretch="None" RenderTransformOrigin="0.5,0.5" Canvas.Left="0" Canvas.Top="0" Width="{Binding ElementName=PART_Track, Path=ActualWidth}" Height="{Binding ElementName=PART_Track, Path=ActualHeight}">
                <ed:Arc.RenderTransform>
                  <RotateTransform Angle="-90" />
                </ed:Arc.RenderTransform>
              </ed:Arc>
              <ed:Arc x:Name="PART_Arc" Stroke="{TemplateBinding Foreground}" StrokeThickness="{Binding BorderThickness, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource ThicknessToDoubleConverter}}" StartAngle="0" EndAngle="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Percent, Converter={StaticResource PercentToAngleConverter}}" Stretch="None" RenderTransformOrigin="0.5,0.5" Canvas.Left="0" Canvas.Top="0" Width="{Binding ElementName=PART_Track, Path=ActualWidth}" Height="{Binding ElementName=PART_Track, Path=ActualHeight}">
                <ed:Arc.RenderTransform>
                  <RotateTransform Angle="-90" />
                </ed:Arc.RenderTransform>
              </ed:Arc>
              <Canvas x:Name="PART_BusyBar" Canvas.Left="0" Canvas.Top="0" Visibility="Hidden">
                <Ellipse Fill="{TemplateBinding Foreground}" StrokeThickness="0" Width="{TemplateBinding params:Progress.BusyElementSize}" Height="{TemplateBinding params:Progress.BusyElementSize}">
                  <Canvas.Left>
                    <MultiBinding Converter="{StaticResource AngleToCoordinateConverter}" ConverterParameter="X">
                      <Binding RelativeSource="{RelativeSource TemplatedParent}" Path="(params:Progress.BusyElementSize)" Converter="{StaticResource NumberPositiveToNegativeConverter}" />
                      <Binding RelativeSource="{RelativeSource Self}" Path="(controls:ProgressRing.Angle)" />
                      <Binding ElementName="PART_Track" Path="ActualWidth" />
                      <Binding ElementName="PART_Track" Path="ActualHeight" />
                      <Binding RelativeSource="{RelativeSource TemplatedParent}" Path="(params:Progress.BusyElementSize)" />
                      <Binding RelativeSource="{RelativeSource TemplatedParent}" Path="(params:Progress.BusyElementSize)" />
                    </MultiBinding>
                  </Canvas.Left>
                  <Canvas.Top>
                    <MultiBinding Converter="{StaticResource AngleToCoordinateConverter}" ConverterParameter="Y">
                      <Binding RelativeSource="{RelativeSource TemplatedParent}" Path="(params:Progress.BusyElementSize)" Converter="{StaticResource NumberPositiveToNegativeConverter}" />
                      <Binding RelativeSource="{RelativeSource Self}" Path="(controls:ProgressRing.Angle)" />
                      <Binding ElementName="PART_Track" Path="ActualWidth" />
                      <Binding ElementName="PART_Track" Path="ActualHeight" />
                      <Binding RelativeSource="{RelativeSource TemplatedParent}" Path="(params:Progress.BusyElementSize)" />
                      <Binding RelativeSource="{RelativeSource TemplatedParent}" Path="(params:Progress.BusyElementSize)" />
                    </MultiBinding>
                  </Canvas.Top>
                </Ellipse>
                <Ellipse Fill="{TemplateBinding Foreground}" StrokeThickness="0" Width="{TemplateBinding params:Progress.BusyElementSize}" Height="{TemplateBinding params:Progress.BusyElementSize}">
                  <Canvas.Left>
                    <MultiBinding Converter="{StaticResource AngleToCoordinateConverter}" ConverterParameter="X">
                      <Binding RelativeSource="{RelativeSource TemplatedParent}" Path="(params:Progress.BusyElementSize)" Converter="{StaticResource NumberPositiveToNegativeConverter}" />
                      <Binding RelativeSource="{RelativeSource Self}" Path="(controls:ProgressRing.Angle)" />
                      <Binding ElementName="PART_Track" Path="ActualWidth" />
                      <Binding ElementName="PART_Track" Path="ActualHeight" />
                      <Binding RelativeSource="{RelativeSource TemplatedParent}" Path="(params:Progress.BusyElementSize)" />
                      <Binding RelativeSource="{RelativeSource TemplatedParent}" Path="(params:Progress.BusyElementSize)" />
                    </MultiBinding>
                  </Canvas.Left>
                  <Canvas.Top>
                    <MultiBinding Converter="{StaticResource AngleToCoordinateConverter}" ConverterParameter="Y">
                      <Binding RelativeSource="{RelativeSource TemplatedParent}" Path="(params:Progress.BusyElementSize)" Converter="{StaticResource NumberPositiveToNegativeConverter}" />
                      <Binding RelativeSource="{RelativeSource Self}" Path="(controls:ProgressRing.Angle)" />
                      <Binding ElementName="PART_Track" Path="ActualWidth" />
                      <Binding ElementName="PART_Track" Path="ActualHeight" />
                      <Binding RelativeSource="{RelativeSource TemplatedParent}" Path="(params:Progress.BusyElementSize)" />
                      <Binding RelativeSource="{RelativeSource TemplatedParent}" Path="(params:Progress.BusyElementSize)" />
                    </MultiBinding>
                  </Canvas.Top>
                </Ellipse>
                <Ellipse Fill="{TemplateBinding Foreground}" StrokeThickness="0" Width="{TemplateBinding params:Progress.BusyElementSize}" Height="{TemplateBinding params:Progress.BusyElementSize}">
                  <Canvas.Left>
                    <MultiBinding Converter="{StaticResource AngleToCoordinateConverter}" ConverterParameter="X">
                      <Binding RelativeSource="{RelativeSource TemplatedParent}" Path="(params:Progress.BusyElementSize)" Converter="{StaticResource NumberPositiveToNegativeConverter}" />
                      <Binding RelativeSource="{RelativeSource Self}" Path="(controls:ProgressRing.Angle)" />
                      <Binding ElementName="PART_Track" Path="ActualWidth" />
                      <Binding ElementName="PART_Track" Path="ActualHeight" />
                      <Binding RelativeSource="{RelativeSource TemplatedParent}" Path="(params:Progress.BusyElementSize)" />
                      <Binding RelativeSource="{RelativeSource TemplatedParent}" Path="(params:Progress.BusyElementSize)" />
                    </MultiBinding>
                  </Canvas.Left>
                  <Canvas.Top>
                    <MultiBinding Converter="{StaticResource AngleToCoordinateConverter}" ConverterParameter="Y">
                      <Binding RelativeSource="{RelativeSource TemplatedParent}" Path="(params:Progress.BusyElementSize)" Converter="{StaticResource NumberPositiveToNegativeConverter}" />
                      <Binding RelativeSource="{RelativeSource Self}" Path="(controls:ProgressRing.Angle)" />
                      <Binding ElementName="PART_Track" Path="ActualWidth" />
                      <Binding ElementName="PART_Track" Path="ActualHeight" />
                      <Binding RelativeSource="{RelativeSource TemplatedParent}" Path="(params:Progress.BusyElementSize)" />
                      <Binding RelativeSource="{RelativeSource TemplatedParent}" Path="(params:Progress.BusyElementSize)" />
                    </MultiBinding>
                  </Canvas.Top>
                </Ellipse>
                <Ellipse Fill="{TemplateBinding Foreground}" StrokeThickness="0" Width="{TemplateBinding params:Progress.BusyElementSize}" Height="{TemplateBinding params:Progress.BusyElementSize}">
                  <Canvas.Left>
                    <MultiBinding Converter="{StaticResource AngleToCoordinateConverter}" ConverterParameter="X">
                      <Binding RelativeSource="{RelativeSource TemplatedParent}" Path="(params:Progress.BusyElementSize)" Converter="{StaticResource NumberPositiveToNegativeConverter}" />
                      <Binding RelativeSource="{RelativeSource Self}" Path="(controls:ProgressRing.Angle)" />
                      <Binding ElementName="PART_Track" Path="ActualWidth" />
                      <Binding ElementName="PART_Track" Path="ActualHeight" />
                      <Binding RelativeSource="{RelativeSource TemplatedParent}" Path="(params:Progress.BusyElementSize)" />
                      <Binding RelativeSource="{RelativeSource TemplatedParent}" Path="(params:Progress.BusyElementSize)" />
                    </MultiBinding>
                  </Canvas.Left>
                  <Canvas.Top>
                    <MultiBinding Converter="{StaticResource AngleToCoordinateConverter}" ConverterParameter="Y">
                      <Binding RelativeSource="{RelativeSource TemplatedParent}" Path="(params:Progress.BusyElementSize)" Converter="{StaticResource NumberPositiveToNegativeConverter}" />
                      <Binding RelativeSource="{RelativeSource Self}" Path="(controls:ProgressRing.Angle)" />
                      <Binding ElementName="PART_Track" Path="ActualWidth" />
                      <Binding ElementName="PART_Track" Path="ActualHeight" />
                      <Binding RelativeSource="{RelativeSource TemplatedParent}" Path="(params:Progress.BusyElementSize)" />
                      <Binding RelativeSource="{RelativeSource TemplatedParent}" Path="(params:Progress.BusyElementSize)" />
                    </MultiBinding>
                  </Canvas.Top>
                </Ellipse>
                <Ellipse Fill="{TemplateBinding Foreground}" StrokeThickness="0" Width="{TemplateBinding params:Progress.BusyElementSize}" Height="{TemplateBinding params:Progress.BusyElementSize}">
                  <Canvas.Left>
                    <MultiBinding Converter="{StaticResource AngleToCoordinateConverter}" ConverterParameter="X">
                      <Binding RelativeSource="{RelativeSource TemplatedParent}" Path="(params:Progress.BusyElementSize)" Converter="{StaticResource NumberPositiveToNegativeConverter}" />
                      <Binding RelativeSource="{RelativeSource Self}" Path="(controls:ProgressRing.Angle)" />
                      <Binding ElementName="PART_Track" Path="ActualWidth" />
                      <Binding ElementName="PART_Track" Path="ActualHeight" />
                      <Binding RelativeSource="{RelativeSource TemplatedParent}" Path="(params:Progress.BusyElementSize)" />
                      <Binding RelativeSource="{RelativeSource TemplatedParent}" Path="(params:Progress.BusyElementSize)" />
                    </MultiBinding>
                  </Canvas.Left>
                  <Canvas.Top>
                    <MultiBinding Converter="{StaticResource AngleToCoordinateConverter}" ConverterParameter="Y">
                      <Binding RelativeSource="{RelativeSource TemplatedParent}" Path="(params:Progress.BusyElementSize)" Converter="{StaticResource NumberPositiveToNegativeConverter}" />
                      <Binding RelativeSource="{RelativeSource Self}" Path="(controls:ProgressRing.Angle)" />
                      <Binding ElementName="PART_Track" Path="ActualWidth" />
                      <Binding ElementName="PART_Track" Path="ActualHeight" />
                      <Binding RelativeSource="{RelativeSource TemplatedParent}" Path="(params:Progress.BusyElementSize)" />
                      <Binding RelativeSource="{RelativeSource TemplatedParent}" Path="(params:Progress.BusyElementSize)" />
                    </MultiBinding>
                  </Canvas.Top>
                </Ellipse>
              </Canvas>
            </Canvas>
          </Border>
          <ControlTemplate.Triggers>
            <MultiTrigger>
              <MultiTrigger.Conditions>
                <Condition Property="State" Value="Busy" />
                <Condition Property="IsEnabled" Value="True" />
              </MultiTrigger.Conditions>
              <MultiTrigger.Setters>
                <Setter TargetName="BackgroundArc" Property="Visibility" Value="Hidden" />
                <Setter TargetName="PART_Arc" Property="Visibility" Value="Hidden" />
                <Setter TargetName="PART_BusyBar" Property="Visibility" Value="Visible" />
              </MultiTrigger.Setters>
            </MultiTrigger>
          </ControlTemplate.Triggers>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
    <Style.Triggers>
      <Trigger Property="State" Value="Indeterminate">
        <Setter Property="BorderBrush" Value="{x:Null}" />
      </Trigger>
      <Trigger Property="State" Value="Busy">
        <Setter Property="BorderBrush" Value="{x:Null}" />
      </Trigger>
      <Trigger Property="IsEnabled" Value="False">
        <Setter Property="Foreground" Value="{StaticResource DisabledBrush}" />
      </Trigger>
    </Style.Triggers>
  </Style>
  <Style x:Key="SliderRepeatButtonStyle" TargetType="{x:Type RepeatButton}">
    <Setter Property="Background" Value="{StaticResource MiddleLightBrush}" />
    <Setter Property="FocusVisualStyle" Value="{x:Null}" />
    <Setter Property="Focusable" Value="False" />
    <Setter Property="Stylus.IsFlicksEnabled" Value="False" />
    <Setter Property="Stylus.IsPressAndHoldEnabled" Value="False" />
    <!-- Temporary removed to fix bugs 1144, 1174, 1216 -->
    <!--<Setter Property="OverridesDefaultStyle" Value="True"/>-->
    <Setter Property="SnapsToDevicePixels" Value="True" />
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type RepeatButton}">
          <Rectangle Fill="{TemplateBinding Background}" StrokeThickness="0" Width="{TemplateBinding Width}" Height="{TemplateBinding Height}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
        </ControlTemplate>
      </Setter.Value>
    </Setter>
    <Style.Triggers>
      <Trigger Property="IsEnabled" Value="False">
        <Setter Property="Background" Value="{StaticResource HighlightBrush}" />
      </Trigger>
    </Style.Triggers>
  </Style>
  <Style x:Key="SliderRepeatButtonValuableStyle" TargetType="{x:Type RepeatButton}" BasedOn="{StaticResource SliderRepeatButtonStyle}">
    <Setter Property="Background" Value="{StaticResource AccentBrush}" />
    <Style.Triggers>
      <Trigger Property="IsEnabled" Value="False">
        <Setter Property="Background" Value="{StaticResource DisabledBrush}" />
      </Trigger>
    </Style.Triggers>
  </Style>
  <Style x:Key="SliderThumbStyle" TargetType="{x:Type Thumb}">
    <Setter Property="Background" Value="{StaticResource MiddleLightBrush}" />
    <Setter Property="BorderBrush" Value="{StaticResource BackgroundBrush}" />
    <Setter Property="FocusVisualStyle" Value="{x:Null}" />
    <Setter Property="Focusable" Value="False" />
    <Setter Property="Stylus.IsFlicksEnabled" Value="False" />
    <Setter Property="Stylus.IsPressAndHoldEnabled" Value="False" />
    <!-- Temporary removed to fix bugs 1144, 1174, 1216 -->
    <!--<Setter Property="OverridesDefaultStyle" Value="True"/>-->
    <Setter Property="SnapsToDevicePixels" Value="True" />
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type Thumb}">
          <Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Width="{TemplateBinding Width}" Height="{TemplateBinding Height}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
        </ControlTemplate>
      </Setter.Value>
    </Setter>
    <Style.Triggers>
      <Trigger Property="IsMouseOver" Value="True">
        <Setter Property="Background" Value="{StaticResource LowlightBrush}" />
      </Trigger>
      <Trigger Property="IsDragging" Value="True">
        <Setter Property="Background" Value="{StaticResource LowlightBrush}" />
      </Trigger>
      <Trigger Property="IsEnabled" Value="False">
        <Setter Property="Background" Value="{StaticResource DisabledBrush}" />
      </Trigger>
    </Style.Triggers>
  </Style>
  <ControlTemplate x:Key="HorizontalSliderTemplate" TargetType="{x:Type Slider}">
    <Grid Background="{TemplateBinding Background}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">
      <Grid.RowDefinitions>
        <RowDefinition Height="Auto" />
        <RowDefinition Height="Auto" />
        <RowDefinition Height="Auto" />
      </Grid.RowDefinitions>
      <TickBar Grid.Row="0" Fill="{TemplateBinding BorderBrush}" Placement="Top" Height="{TemplateBinding params:Slider.TrackSize}" Visibility="Collapsed" />
      <Rectangle x:Name="PART_SelectionRange" Grid.Row="1" Fill="{StaticResource ForegroundBrush}" StrokeThickness="0" Height="{TemplateBinding params:Slider.TrackSize}" Visibility="Hidden" />
      <Track x:Name="PART_Track" Grid.Row="1" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
        <Track.DecreaseRepeatButton>
          <RepeatButton Command="{x:Static Slider.DecreaseLarge}" IsEnabled="{TemplateBinding IsEnabled}" Height="{TemplateBinding params:Slider.TrackSize}" Style="{StaticResource SliderRepeatButtonValuableStyle}" />
        </Track.DecreaseRepeatButton>
        <Track.Thumb>
          <Thumb BorderThickness="{Binding RelativeSource={RelativeSource Self}, Path=(params:General.DefaultPaddingValue), Mode=OneWay, Converter={StaticResource DoubleToThicknessConverter}, ConverterParameter=Right}" IsEnabled="{TemplateBinding IsEnabled}" Width="{TemplateBinding params:Slider.ThumbThickness}" Height="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=ActualHeight, Mode=OneWay}" Style="{StaticResource SliderThumbStyle}" />
        </Track.Thumb>
        <Track.IncreaseRepeatButton>
          <RepeatButton Command="{x:Static Slider.IncreaseLarge}" IsEnabled="{TemplateBinding IsEnabled}" Height="{TemplateBinding params:Slider.TrackSize}" Style="{StaticResource SliderRepeatButtonStyle}" />
        </Track.IncreaseRepeatButton>
      </Track>
      <TickBar Grid.Row="2" Fill="{TemplateBinding BorderBrush}" Placement="Bottom" Height="{TemplateBinding params:Slider.TrackSize}" Visibility="Collapsed" />
    </Grid>
  </ControlTemplate>
  <ControlTemplate x:Key="VerticalSliderTemplate" TargetType="{x:Type Slider}">
    <Grid Background="{TemplateBinding Background}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">
      <Grid.ColumnDefinitions>
        <ColumnDefinition Width="Auto" />
        <ColumnDefinition Width="Auto" />
        <ColumnDefinition Width="Auto" />
      </Grid.ColumnDefinitions>
      <TickBar Grid.Column="0" Fill="{TemplateBinding BorderBrush}" Placement="Top" Width="{TemplateBinding params:Slider.TrackSize}" Visibility="Collapsed" />
      <Rectangle x:Name="PART_SelectionRange" Grid.Column="1" Fill="{StaticResource ForegroundBrush}" StrokeThickness="0" Width="{TemplateBinding params:Slider.TrackSize}" Visibility="Hidden" />
      <Track x:Name="PART_Track" Grid.Column="1" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
        <Track.DecreaseRepeatButton>
          <RepeatButton Command="{x:Static Slider.DecreaseLarge}" IsEnabled="{TemplateBinding IsEnabled}" Width="{TemplateBinding params:Slider.TrackSize}" Style="{StaticResource SliderRepeatButtonValuableStyle}" />
        </Track.DecreaseRepeatButton>
        <Track.Thumb>
          <Thumb BorderThickness="{Binding RelativeSource={RelativeSource Self}, Path=(params:General.DefaultPaddingValue), Mode=OneWay, Converter={StaticResource DoubleToThicknessConverter}, ConverterParameter=Top}" IsEnabled="{TemplateBinding IsEnabled}" Width="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=ActualWidth, Mode=OneWay}" Height="{TemplateBinding params:Slider.ThumbThickness}" Style="{StaticResource SliderThumbStyle}" />
        </Track.Thumb>
        <Track.IncreaseRepeatButton>
          <RepeatButton Command="{x:Static Slider.IncreaseLarge}" IsEnabled="{TemplateBinding IsEnabled}" Width="{TemplateBinding params:Slider.TrackSize}" Style="{StaticResource SliderRepeatButtonStyle}" />
        </Track.IncreaseRepeatButton>
      </Track>
      <TickBar Grid.Column="2" Fill="{TemplateBinding BorderBrush}" Placement="Bottom" Width="{TemplateBinding params:Slider.TrackSize}" Visibility="Collapsed" />
    </Grid>
  </ControlTemplate>
  <Style TargetType="{x:Type Slider}">
    <Setter Property="Background" Value="{x:Null}" />
    <Setter Property="BorderBrush" Value="{StaticResource MiddleLightBrush}" />
    <Setter Property="BorderThickness" Value="0" />
    <Setter Property="Foreground" Value="{StaticResource ForegroundBrush}" />
    <Setter Property="FontSize" Value="{Binding RelativeSource={RelativeSource Self}, Path=(params:General.ContentFontSize), Mode=OneWay}" />
    <Setter Property="FontStretch" Value="Medium" />
    <Setter Property="FontStyle" Value="Normal" />
    <Setter Property="FontWeight" Value="Normal" />
    <Setter Property="FocusVisualStyle" Value="{x:Null}" />
    <Setter Property="Focusable" Value="False" />
    <Setter Property="Stylus.IsPressAndHoldEnabled" Value="False" />
    <!-- Temporary removed to fix bugs 1144, 1174, 1216 -->
    <!--<Setter Property="OverridesDefaultStyle" Value="True"/>-->
    <Setter Property="SnapsToDevicePixels" Value="True" />
    <Style.Triggers>
      <Trigger Property="IsEnabled" Value="False">
        <Setter Property="BorderBrush" Value="{StaticResource DisabledBrush}" />
      </Trigger>
      <Trigger Property="Orientation" Value="Horizontal">
        <Setter Property="MinHeight" Value="14" />
        <Setter Property="Height" Value="18" />
        <Setter Property="MaxHeight" Value="22" />
        <Setter Property="Template" Value="{StaticResource HorizontalSliderTemplate}" />
      </Trigger>
      <Trigger Property="Orientation" Value="Vertical">
        <Setter Property="MinWidth" Value="14" />
        <Setter Property="Width" Value="18" />
        <Setter Property="MaxWidth" Value="22" />
        <Setter Property="Template" Value="{StaticResource VerticalSliderTemplate}" />
      </Trigger>
    </Style.Triggers>
  </Style>
  <Style x:Key="ToggleSwitchSwitchStyle" TargetType="{x:Type Button}">
    <Setter Property="Background" Value="{StaticResource HighlightBrush}" />
    <Setter Property="FocusVisualStyle" Value="{x:Null}" />
    <Setter Property="Focusable" Value="False" />
    <Setter Property="Stylus.IsFlicksEnabled" Value="False" />
    <Setter Property="Stylus.IsPressAndHoldEnabled" Value="False" />
    <!-- Temporary removed to fix bugs 1144, 1174, 1216 -->
    <!--<Setter Property="OverridesDefaultStyle" Value="True"/>-->
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type Button}">
          <Rectangle Fill="{TemplateBinding Background}" StrokeThickness="0" />
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>
  <Style x:Key="ToggleSwitchThumbStyle" TargetType="{x:Type Thumb}">
    <Setter Property="Background" Value="{StaticResource MiddleLightBrush}" />
    <Setter Property="FocusVisualStyle" Value="{x:Null}" />
    <Setter Property="Focusable" Value="False" />
    <Setter Property="Stylus.IsFlicksEnabled" Value="False" />
    <Setter Property="Stylus.IsPressAndHoldEnabled" Value="False" />
    <!-- Temporary removed to fix bugs 1144, 1174, 1216 -->
    <!--<Setter Property="OverridesDefaultStyle" Value="True"/>-->
    <Setter Property="SnapsToDevicePixels" Value="True" />
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type Thumb}">
          <Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Width="{TemplateBinding Width}" Height="{TemplateBinding Height}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
        </ControlTemplate>
      </Setter.Value>
    </Setter>
    <Style.Triggers>
      <Trigger Property="IsMouseOver" Value="True">
        <Setter Property="Background" Value="{StaticResource LowlightBrush}" />
      </Trigger>
      <Trigger Property="IsDragging" Value="True">
        <Setter Property="Background" Value="{StaticResource LowlightBrush}" />
      </Trigger>
      <Trigger Property="IsEnabled" Value="False">
        <Setter Property="Background" Value="{StaticResource DisabledBrush}" />
      </Trigger>
    </Style.Triggers>
  </Style>
  <Style x:Key="{x:Type controls:ToggleSwitch}" TargetType="{x:Type controls:ToggleSwitch}">
    <Setter Property="Background" Value="{StaticResource BackgroundBrush}" />
    <Setter Property="BorderBrush" Value="{StaticResource MiddleLightBrush}" />
    <Setter Property="BorderThickness" Value="{Binding RelativeSource={RelativeSource Self}, Path=(params:General.DefaultThickness), Mode=OneWay}" />
    <Setter Property="Foreground" Value="{StaticResource ForegroundBrush}" />
    <Setter Property="FontSize" Value="{Binding RelativeSource={RelativeSource Self}, Path=(params:General.ContentFontSize), Mode=OneWay}" />
    <Setter Property="FontStretch" Value="Medium" />
    <Setter Property="FontStyle" Value="Normal" />
    <Setter Property="FontWeight" Value="Normal" />
    <Setter Property="TextOptions.TextFormattingMode" Value="Display" />
    <Setter Property="TextOptions.TextRenderingMode" Value="ClearType" />
    <Setter Property="RenderOptions.ClearTypeHint" Value="Enabled" />
    <Setter Property="FocusVisualStyle" Value="{x:Null}" />
    <Setter Property="Focusable" Value="False" />
    <Setter Property="Stylus.IsPressAndHoldEnabled" Value="False" />
    <Setter Property="Padding" Value="0" />
    <Setter Property="MinHeight" Value="12" />
    <Setter Property="Height" Value="16" />
    <Setter Property="MaxHeight" Value="20" />
    <Setter Property="SnapsToDevicePixels" Value="True" />
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type controls:ToggleSwitch}">
          <Grid Background="{x:Null}" TextBlock.Foreground="{TemplateBinding Foreground}" TextBlock.FontFamily="{TemplateBinding FontFamily}" TextBlock.FontSize="{TemplateBinding FontSize}" TextBlock.FontStretch="{TemplateBinding FontStretch}" TextBlock.FontStyle="{TemplateBinding FontStyle}" TextBlock.FontWeight="{TemplateBinding FontWeight}" TextOptions.TextFormattingMode="{TemplateBinding TextOptions.TextFormattingMode}" TextOptions.TextRenderingMode="{TemplateBinding TextOptions.TextRenderingMode}" RenderOptions.ClearTypeHint="{TemplateBinding RenderOptions.ClearTypeHint}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">
            <Grid.ColumnDefinitions>
              <ColumnDefinition Width="Auto" />
              <ColumnDefinition Width="*" />
              <ColumnDefinition Width="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(params:ToggleSwitch.TrackSize), Mode=OneWay, Converter={StaticResource DoubleToGridLengthConverter}}" />
            </Grid.ColumnDefinitions>
            <ContentPresenter x:Name="OnHeaderHost" Grid.Column="0" Content="{TemplateBinding OnHeader}" ContentStringFormat="{TemplateBinding OnHeaderStringFormat}" ContentTemplate="{TemplateBinding OnHeaderTemplate}" ContentTemplateSelector="{TemplateBinding OnHeaderTemplateSelector}" HorizontalAlignment="Left" VerticalAlignment="Center" Visibility="Collapsed" />
            <ContentPresenter x:Name="OffHeaderHost" Grid.Column="0" Content="{TemplateBinding OffHeader}" ContentStringFormat="{TemplateBinding OffHeaderStringFormat}" ContentTemplate="{TemplateBinding OffHeaderTemplate}" ContentTemplateSelector="{TemplateBinding OffHeaderTemplateSelector}" HorizontalAlignment="Left" VerticalAlignment="Center" Visibility="Collapsed" />
            <Border x:Name="PART_Track" Grid.Column="2" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}">
              <DockPanel>
                <Rectangle x:Name="PART_Fill" DockPanel.Dock="Left" Fill="{StaticResource AccentBrush}" Margin="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(params:General.DefaultThicknessValue), Mode=OneWay, Converter={StaticResource DoubleToThicknessConverter}, ConverterParameter='Left, Top, Bottom'}" Width="0" />
                <Thumb x:Name="PART_Thumb" DockPanel.Dock="Left" BorderBrush="{TemplateBinding Background}" BorderThickness="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(params:General.DefaultThicknessValue), Mode=OneWay, Converter={StaticResource DoubleToThicknessConverter}, ConverterParameter=Right}" IsEnabled="{TemplateBinding IsEnabled}" Margin="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=BorderThickness, Mode=OneWay, Converter={StaticResource ThicknessPositiveToNegativeConverter}}" Width="{TemplateBinding params:ToggleSwitch.ThumbThickness}" Style="{StaticResource ToggleSwitchThumbStyle}" />
                <Button x:Name="PART_Switch" Margin="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(params:General.DefaultThicknessValue), Mode=OneWay, Converter={StaticResource DoubleToThicknessConverter}, ConverterParameter='Right, Top, Bottom'}" Style="{StaticResource ToggleSwitchSwitchStyle}" />
              </DockPanel>
            </Border>
          </Grid>
          <ControlTemplate.Triggers>
            <Trigger Property="IsChecked" Value="False">
              <Setter TargetName="OffHeaderHost" Property="Visibility" Value="Visible" />
            </Trigger>
            <Trigger Property="IsChecked" Value="True">
              <Setter TargetName="OnHeaderHost" Property="Visibility" Value="Visible" />
              <Setter TargetName="PART_Fill" Property="DockPanel.Dock" Value="Right" />
              <Setter TargetName="PART_Fill" Property="Fill" Value="{StaticResource HighlightBrush}" />
              <Setter TargetName="PART_Fill" Property="Margin" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(params:General.DefaultThicknessValue), Mode=OneWay, Converter={StaticResource DoubleToThicknessConverter}, ConverterParameter='Right, Top, Bottom'}" />
              <Setter TargetName="PART_Thumb" Property="DockPanel.Dock" Value="Right" />
              <Setter TargetName="PART_Thumb" Property="BorderThickness" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(params:General.DefaultThicknessValue), Mode=OneWay, Converter={StaticResource DoubleToThicknessConverter}, ConverterParameter=Left}" />
              <Setter TargetName="PART_Thumb" Property="Margin" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=BorderThickness, Mode=OneWay, Converter={StaticResource ThicknessPositiveToNegativeConverter}}" />
              <Setter TargetName="PART_Switch" Property="Margin" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(params:General.DefaultThicknessValue), Mode=OneWay, Converter={StaticResource DoubleToThicknessConverter}, ConverterParameter='Left, Top, Bottom'}" />
            </Trigger>
            <MultiTrigger>
              <MultiTrigger.Conditions>
                <Condition Property="IsChecked" Value="True" />
                <Condition Property="IsEnabled" Value="True" />
              </MultiTrigger.Conditions>
              <MultiTrigger.Setters>
                <Setter TargetName="PART_Switch" Property="Background" Value="{StaticResource AccentBrush}" />
              </MultiTrigger.Setters>
            </MultiTrigger>
            <MultiTrigger>
              <MultiTrigger.Conditions>
                <Condition Property="IsSwitching" Value="True" />
                <Condition Property="IsChecked" Value="False" />
              </MultiTrigger.Conditions>
              <MultiTrigger.Setters>
                <Setter TargetName="PART_Thumb" Property="BorderThickness" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(params:General.DefaultThicknessValue), Mode=OneWay, Converter={StaticResource DoubleToThicknessConverter}, ConverterParameter=Left}" />
              </MultiTrigger.Setters>
            </MultiTrigger>
            <MultiTrigger>
              <MultiTrigger.Conditions>
                <Condition Property="IsSwitching" Value="True" />
                <Condition Property="IsChecked" Value="True" />
              </MultiTrigger.Conditions>
              <MultiTrigger.Setters>
                <Setter TargetName="PART_Thumb" Property="BorderThickness" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(params:General.DefaultThicknessValue), Mode=OneWay, Converter={StaticResource DoubleToThicknessConverter}, ConverterParameter=Right}" />
              </MultiTrigger.Setters>
            </MultiTrigger>
          </ControlTemplate.Triggers>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
    <Style.Triggers>
      <DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=FontSize, Mode=OneWay, Converter={StaticResource IsGreaterThanConverter}, ConverterParameter=18}">
        <Setter Property="TextOptions.TextFormattingMode" Value="Ideal" />
      </DataTrigger>
      <Trigger Property="IsEnabled" Value="False">
        <Setter Property="Background" Value="{StaticResource BackgroundBrush}" />
        <Setter Property="BorderBrush" Value="{StaticResource DisabledBrush}" />
        <Setter Property="Foreground" Value="{StaticResource DisabledBrush}" />
      </Trigger>
    </Style.Triggers>
  </Style>
  <Style x:Key="TabItemHeaderStyle" TargetType="{x:Type ContentControl}">
    <Setter Property="Background" Value="{StaticResource TransparentBrush}" />
    <Setter Property="BorderBrush" Value="{StaticResource LowlightBrush}" />
    <Setter Property="BorderThickness" Value="0" />
    <Setter Property="Foreground" Value="{StaticResource LowlightBrush}" />
    <Setter Property="FontSize" Value="{Binding RelativeSource={RelativeSource Self}, Path=(params:General.HeaderFontSize), Mode=OneWay}" />
    <Setter Property="FontStretch" Value="Medium" />
    <Setter Property="FontStyle" Value="Normal" />
    <Setter Property="FontWeight" Value="Normal" />
    <Setter Property="TextOptions.TextFormattingMode" Value="Display" />
    <Setter Property="TextOptions.TextRenderingMode" Value="ClearType" />
    <Setter Property="RenderOptions.ClearTypeHint" Value="Enabled" />
    <Setter Property="FocusVisualStyle" Value="{StaticResource FocusVisualStyle}" />
    <Setter Property="Focusable" Value="True" />
    <Setter Property="HorizontalContentAlignment" Value="Stretch" />
    <Setter Property="VerticalContentAlignment" Value="Stretch" />
    <Setter Property="Padding" Value="{Binding RelativeSource={RelativeSource Self}, Path=(params:General.BoldPadding), Mode=OneWay}" />
    <Setter Property="SnapsToDevicePixels" Value="True" />
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type ContentControl}">
          <Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}">
            <Grid TextBlock.Foreground="{TemplateBinding Foreground}" TextBlock.FontFamily="{TemplateBinding FontFamily}" TextBlock.FontSize="{TemplateBinding FontSize}" TextBlock.FontStretch="{TemplateBinding FontStretch}" TextBlock.FontStyle="{TemplateBinding FontStyle}" TextBlock.FontWeight="{TemplateBinding FontWeight}" TextOptions.TextFormattingMode="{TemplateBinding TextOptions.TextFormattingMode}" TextOptions.TextRenderingMode="{TemplateBinding TextOptions.TextRenderingMode}" RenderOptions.ClearTypeHint="{TemplateBinding RenderOptions.ClearTypeHint}" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
              <Rectangle x:Name="Indicator" Fill="{Binding RelativeSource={RelativeSource AncestorType={x:Type TabItem}}, Path=(params:TabControl.IndicatorBrush)}" StrokeThickness="0" Height="{Binding RelativeSource={RelativeSource AncestorType={x:Type TabControl}}, Path=(params:TabControl.IndicatorThickness)}" HorizontalAlignment="Stretch" VerticalAlignment="Bottom" />
              <ContentPresenter Margin="{TemplateBinding Padding}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" RecognizesAccessKey="True" />
            </Grid>
          </Border>
          <ControlTemplate.Triggers>
            <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type TabItem}}, Path=TabStripPlacement}" Value="{x:Static Dock.Bottom}">
              <Setter TargetName="Indicator" Property="VerticalAlignment" Value="Top" />
            </DataTrigger>
            <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type TabItem}}, Path=TabStripPlacement}" Value="{x:Static Dock.Left}">
              <Setter Property="LayoutTransform">
                <Setter.Value>
                  <RotateTransform Angle="-90" />
                </Setter.Value>
              </Setter>
              <Setter TargetName="Indicator" Property="VerticalAlignment" Value="Bottom" />
            </DataTrigger>
            <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type TabItem}}, Path=TabStripPlacement}" Value="{x:Static Dock.Right}">
              <Setter Property="LayoutTransform">
                <Setter.Value>
                  <RotateTransform Angle="90" />
                </Setter.Value>
              </Setter>
              <Setter TargetName="Indicator" Property="VerticalAlignment" Value="Bottom" />
            </DataTrigger>
          </ControlTemplate.Triggers>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
    <Style.Triggers>
      <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type TabItem}}, Path=TabStripPlacement}" Value="{x:Static Dock.Left}">
        <Setter Property="TextOptions.TextFormattingMode" Value="Ideal" />
      </DataTrigger>
      <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type TabItem}}, Path=TabStripPlacement}" Value="{x:Static Dock.Right}">
        <Setter Property="TextOptions.TextFormattingMode" Value="Ideal" />
      </DataTrigger>
      <DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=FontSize, Mode=OneWay, Converter={StaticResource IsGreaterThanConverter}, ConverterParameter=18}">
        <Setter Property="TextOptions.TextFormattingMode" Value="Ideal" />
      </DataTrigger>
      <Trigger Property="IsMouseOver" Value="True">
        <Setter Property="Foreground" Value="{StaticResource ForegroundBrush}" />
      </Trigger>
      <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type TabItem}}, Path=IsSelected}" Value="True">
        <Setter Property="BorderBrush" Value="{StaticResource AccentBrush}" />
        <Setter Property="Foreground" Value="{StaticResource ForegroundBrush}" />
      </DataTrigger>
      <Trigger Property="IsEnabled" Value="False">
        <Setter Property="BorderBrush" Value="{StaticResource DisabledBrush}" />
        <Setter Property="Foreground" Value="{StaticResource DisabledBrush}" />
      </Trigger>
    </Style.Triggers>
  </Style>
  <Style TargetType="{x:Type TabItem}">
    <Setter Property="Background" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type TabControl}}, Path=Background, Mode=OneWay}" />
    <Setter Property="BorderBrush" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type TabControl}}, Path=BorderBrush, Mode=OneWay}" />
    <Setter Property="BorderThickness" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type TabControl}}, Path=BorderThickness, Mode=OneWay}" />
    <Setter Property="Foreground" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type TabControl}}, Path=Foreground, Mode=OneWay}" />
    <Setter Property="FontSize" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type TabControl}}, Path=FontSize, Mode=OneWay}" />
    <Setter Property="FontStretch" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type TabControl}}, Path=FontStretch, Mode=OneWay}" />
    <Setter Property="FontStyle" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type TabControl}}, Path=FontStyle, Mode=OneWay}" />
    <Setter Property="FontWeight" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type TabControl}}, Path=FontWeight, Mode=OneWay}" />
    <Setter Property="TextOptions.TextFormattingMode" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type TabControl}}, Path=(TextOptions.TextFormattingMode), Mode=OneWay}" />
    <Setter Property="TextOptions.TextRenderingMode" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type TabControl}}, Path=(TextOptions.TextRenderingMode), Mode=OneWay}" />
    <Setter Property="RenderOptions.ClearTypeHint" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type TabControl}}, Path=(RenderOptions.ClearTypeHint), Mode=OneWay}" />
    <Setter Property="FocusVisualStyle" Value="{StaticResource FocusVisualStyle}" />
    <Setter Property="Focusable" Value="True" />
    <Setter Property="HorizontalContentAlignment" Value="Stretch" />
    <Setter Property="VerticalContentAlignment" Value="Stretch" />
    <Setter Property="Padding" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type TabControl}}, Path=Padding, Mode=OneWay}" />
    <Setter Property="params:TabItem.HeaderStyle" Value="{StaticResource TabItemHeaderStyle}" />
    <Setter Property="params:TabControl.IndicatorBrush" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type TabControl}}, Path=(params:TabControl.IndicatorBrush)}" />
    <!-- Temporary removed to fix bugs 1144, 1174, 1216 -->
    <!--<Setter Property="OverridesDefaultStyle" Value="True"/>-->
    <Setter Property="SnapsToDevicePixels" Value="True" />
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type TabItem}">
          <ContentControl x:Name="ContentHost" Content="{TemplateBinding Header}" TextOptions.TextFormattingMode="{TemplateBinding TextOptions.TextFormattingMode}" TextOptions.TextRenderingMode="{TemplateBinding TextOptions.TextRenderingMode}" RenderOptions.ClearTypeHint="{TemplateBinding RenderOptions.ClearTypeHint}" Style="{TemplateBinding params:TabItem.HeaderStyle}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
        </ControlTemplate>
      </Setter.Value>
    </Setter>
    <Style.Triggers>
      <DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=FontSize, Mode=OneWay, Converter={StaticResource IsGreaterThanConverter}, ConverterParameter=18}">
        <Setter Property="TextOptions.TextFormattingMode" Value="Ideal" />
      </DataTrigger>
      <Trigger Property="IsSelected" Value="True">
        <Setter Property="params:TabControl.IndicatorBrush" Value="{StaticResource AccentBrush}" />
      </Trigger>
    </Style.Triggers>
  </Style>
  <Style TargetType="{x:Type TabControl}">
    <Setter Property="Background" Value="{StaticResource BackgroundBrush}" />
    <Setter Property="BorderBrush" Value="{StaticResource LowlightBrush}" />
    <Setter Property="BorderThickness" Value="0" />
    <Setter Property="params:TabControl.IndicatorBrush" Value="{StaticResource HighlightBrush}" />
    <Setter Property="Foreground" Value="{StaticResource ForegroundBrush}" />
    <Setter Property="FontSize" Value="{Binding RelativeSource={RelativeSource Self}, Path=(params:General.TextFontSize), Mode=OneWay}" />
    <Setter Property="FontStretch" Value="Medium" />
    <Setter Property="FontStyle" Value="Normal" />
    <Setter Property="FontWeight" Value="Normal" />
    <Setter Property="TextOptions.TextFormattingMode" Value="Display" />
    <Setter Property="TextOptions.TextRenderingMode" Value="ClearType" />
    <Setter Property="RenderOptions.ClearTypeHint" Value="Enabled" />
    <Setter Property="ClipToBounds" Value="True" />
    <Setter Property="FocusVisualStyle" Value="{x:Null}" />
    <Setter Property="Focusable" Value="False" />
    <Setter Property="HorizontalContentAlignment" Value="Stretch" />
    <Setter Property="VerticalContentAlignment" Value="Stretch" />
    <Setter Property="Padding" Value="{Binding RelativeSource={RelativeSource Self}, Path=(params:General.BoldPadding), Converter={StaticResource ThicknessConverter}, ConverterParameter='Top', Mode=OneWay}" />
    <!-- Temporary removed to fix bugs 1144, 1174, 1216 -->
    <!--<Setter Property="OverridesDefaultStyle" Value="True"/>-->
    <Setter Property="SnapsToDevicePixels" Value="True" />
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type TabControl}">
          <Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" TextBlock.Foreground="{TemplateBinding Foreground}" TextBlock.FontFamily="{TemplateBinding FontFamily}" TextBlock.FontSize="{TemplateBinding FontSize}" TextBlock.FontStretch="{TemplateBinding FontStretch}" TextBlock.FontStyle="{TemplateBinding FontStyle}" TextBlock.FontWeight="{TemplateBinding FontWeight}" TextOptions.TextFormattingMode="{TemplateBinding TextOptions.TextFormattingMode}" TextOptions.TextRenderingMode="{TemplateBinding TextOptions.TextRenderingMode}" RenderOptions.ClearTypeHint="{TemplateBinding RenderOptions.ClearTypeHint}" KeyboardNavigation.DirectionalNavigation="Local" ClipToBounds="{TemplateBinding ClipToBounds}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">
            <Grid>
              <Grid.ColumnDefinitions>
                <ColumnDefinition x:Name="FirstColumnDefinition" Width="*" />
                <ColumnDefinition x:Name="SecondColumnDefinition" Width="0" />
              </Grid.ColumnDefinitions>
              <Grid.RowDefinitions>
                <RowDefinition x:Name="FirstRowDefinition" Height="Auto" />
                <RowDefinition x:Name="SecondRowDefinition" Height="*" />
              </Grid.RowDefinitions>
              <Rectangle x:Name="Indicator" Grid.Column="0" Grid.Row="0" Fill="{TemplateBinding params:TabControl.IndicatorBrush}" Height="{TemplateBinding params:TabControl.IndicatorThickness}" HorizontalAlignment="Stretch" VerticalAlignment="Bottom" />
              <TabPanel x:Name="HeaderPanel" Grid.Column="0" Grid.Row="0" IsItemsHost="True" KeyboardNavigation.TabIndex="1" />
              <Border x:Name="ContentPanel" Grid.Column="0" Grid.Row="1" Background="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=SelectedItem.(TabItem.Background)}" BorderBrush="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=SelectedItem.(TabItem.BorderBrush)}" BorderThickness="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=SelectedItem.(TabItem.BorderThickness)}" TextBlock.Foreground="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=SelectedItem.(TabItem.Foreground)}" TextBlock.FontFamily="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=SelectedItem.(TabItem.FontFamily)}" TextBlock.FontSize="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=SelectedItem.(TabItem.FontSize)}" TextBlock.FontStretch="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=SelectedItem.(TabItem.FontStretch)}" TextBlock.FontStyle="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=SelectedItem.(TabItem.FontStyle)}" TextBlock.FontWeight="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=SelectedItem.(TabItem.FontWeight)}" TextOptions.TextFormattingMode="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=SelectedItem.(TextOptions.TextFormattingMode)}" TextOptions.TextRenderingMode="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=SelectedItem.(TextOptions.TextRenderingMode)}" RenderOptions.ClearTypeHint="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=SelectedItem.(RenderOptions.ClearTypeHint)}" KeyboardNavigation.DirectionalNavigation="Contained" KeyboardNavigation.TabIndex="2" KeyboardNavigation.TabNavigation="Local">
                <ContentPresenter x:Name="PART_SelectedContentHost" ContentSource="SelectedContent" Margin="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=SelectedItem.(TabItem.Padding)}" HorizontalAlignment="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=SelectedItem.(TabItem.HorizontalContentAlignment), Mode=OneWay, UpdateSourceTrigger=PropertyChanged}" VerticalAlignment="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=SelectedItem.(TabItem.VerticalContentAlignment), Mode=OneWay, UpdateSourceTrigger=PropertyChanged}" />
              </Border>
            </Grid>
          </Border>
          <ControlTemplate.Triggers>
            <Trigger Property="TabStripPlacement" Value="Bottom">
              <Setter TargetName="FirstRowDefinition" Property="Height" Value="*" />
              <Setter TargetName="SecondRowDefinition" Property="Height" Value="Auto" />
              <Setter TargetName="Indicator" Property="Grid.Row" Value="1" />
              <Setter TargetName="HeaderPanel" Property="Grid.Row" Value="1" />
              <Setter TargetName="ContentPanel" Property="Grid.Row" Value="0" />
              <Setter TargetName="Indicator" Property="VerticalAlignment" Value="Top" />
            </Trigger>
            <Trigger Property="TabStripPlacement" Value="Left">
              <Setter TargetName="FirstColumnDefinition" Property="Width" Value="Auto" />
              <Setter TargetName="SecondColumnDefinition" Property="Width" Value="*" />
              <Setter TargetName="FirstRowDefinition" Property="Height" Value="*" />
              <Setter TargetName="SecondRowDefinition" Property="Height" Value="0" />
              <Setter TargetName="Indicator" Property="Grid.Column" Value="0" />
              <Setter TargetName="HeaderPanel" Property="Grid.Column" Value="0" />
              <Setter TargetName="ContentPanel" Property="Grid.Column" Value="1" />
              <Setter TargetName="Indicator" Property="Grid.Row" Value="0" />
              <Setter TargetName="HeaderPanel" Property="Grid.Row" Value="0" />
              <Setter TargetName="ContentPanel" Property="Grid.Row" Value="0" />
              <Setter TargetName="Indicator" Property="Width" Value="{Binding RelativeSource={RelativeSource Self}, Path=(params:TabControl.IndicatorThickness)}" />
              <Setter TargetName="Indicator" Property="Height" Value="NaN" />
              <Setter TargetName="Indicator" Property="HorizontalAlignment" Value="Right" />
              <Setter TargetName="Indicator" Property="VerticalAlignment" Value="Stretch" />
            </Trigger>
            <Trigger Property="TabStripPlacement" Value="Right">
              <Setter TargetName="FirstColumnDefinition" Property="Width" Value="*" />
              <Setter TargetName="SecondColumnDefinition" Property="Width" Value="Auto" />
              <Setter TargetName="FirstRowDefinition" Property="Height" Value="*" />
              <Setter TargetName="SecondRowDefinition" Property="Height" Value="0" />
              <Setter TargetName="Indicator" Property="Grid.Column" Value="1" />
              <Setter TargetName="HeaderPanel" Property="Grid.Column" Value="1" />
              <Setter TargetName="ContentPanel" Property="Grid.Column" Value="0" />
              <Setter TargetName="Indicator" Property="Grid.Row" Value="0" />
              <Setter TargetName="HeaderPanel" Property="Grid.Row" Value="0" />
              <Setter TargetName="ContentPanel" Property="Grid.Row" Value="0" />
              <Setter TargetName="Indicator" Property="Width" Value="{Binding RelativeSource={RelativeSource Self}, Path=(params:TabControl.IndicatorThickness)}" />
              <Setter TargetName="Indicator" Property="Height" Value="NaN" />
              <Setter TargetName="Indicator" Property="HorizontalAlignment" Value="Left" />
              <Setter TargetName="Indicator" Property="VerticalAlignment" Value="Stretch" />
            </Trigger>
          </ControlTemplate.Triggers>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
    <Style.Triggers>
      <DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=FontSize, Mode=OneWay, Converter={StaticResource IsGreaterThanConverter}, ConverterParameter=18}">
        <Setter Property="TextOptions.TextFormattingMode" Value="Ideal" />
      </DataTrigger>
      <Trigger Property="IsEnabled" Value="False">
        <Setter Property="BorderBrush" Value="{StaticResource DisabledBrush}" />
        <Setter Property="Foreground" Value="{StaticResource DisabledBrush}" />
      </Trigger>
    </Style.Triggers>
  </Style>
  <Style x:Key="{x:Type primitives:CommandButtonBase}" TargetType="{x:Type primitives:CommandButtonBase}">
    <Setter Property="Background" Value="{StaticResource BackgroundBrush}" />
    <Setter Property="BorderBrush" Value="{StaticResource LowlightBrush}" />
    <Setter Property="BorderThickness" Value="{Binding RelativeSource={RelativeSource Self}, Path=(params:General.BoldThickness), Mode=OneWay}" />
    <Setter Property="params:CommandButtons.Mask" Value="{StaticResource LowlightBrush}" />
    <Setter Property="Foreground" Value="{StaticResource ForegroundBrush}" />
    <Setter Property="FontSize" Value="{Binding RelativeSource={RelativeSource Self}, Path=(params:General.ContentFontSize), Mode=OneWay}" />
    <Setter Property="FontStretch" Value="Medium" />
    <Setter Property="FontStyle" Value="Normal" />
    <Setter Property="FontWeight" Value="Normal" />
    <Setter Property="TextOptions.TextFormattingMode" Value="Display" />
    <Setter Property="TextOptions.TextRenderingMode" Value="ClearType" />
    <Setter Property="RenderOptions.ClearTypeHint" Value="Enabled" />
    <Setter Property="FocusVisualStyle" Value="{StaticResource FocusVisualStyle}" />
    <Setter Property="Padding" Value="{Binding RelativeSource={RelativeSource Self}, Path=(params:General.SemiBoldPadding), Mode=OneWay}" />
    <Setter Property="SnapsToDevicePixels" Value="True" />
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type primitives:CommandButtonBase}">
          <Grid Background="{StaticResource TransparentBrush}" TextBlock.Foreground="{TemplateBinding Foreground}" TextBlock.FontFamily="{TemplateBinding FontFamily}" TextBlock.FontSize="{TemplateBinding FontSize}" TextBlock.FontStretch="{TemplateBinding FontStretch}" TextBlock.FontStyle="{TemplateBinding FontStyle}" TextBlock.FontWeight="{TemplateBinding FontWeight}" TextOptions.TextFormattingMode="{TemplateBinding TextOptions.TextFormattingMode}" TextOptions.TextRenderingMode="{TemplateBinding TextOptions.TextRenderingMode}" RenderOptions.ClearTypeHint="{TemplateBinding RenderOptions.ClearTypeHint}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">
            <Grid.RowDefinitions>
              <RowDefinition Height="*" />
              <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>
            <Ellipse x:Name="PART_Decor" Grid.Row="0" Fill="{TemplateBinding Background}" Stroke="{TemplateBinding BorderBrush}" StrokeThickness="{Binding BorderThickness, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource ThicknessToDoubleConverter}}" Stretch="Fill" HorizontalAlignment="Center" VerticalAlignment="Center" />
            <ContentPresenter x:Name="PART_ContentHost" Grid.Row="0" Content="{TemplateBinding Content}" ContentStringFormat="{TemplateBinding ContentStringFormat}" ContentTemplate="{TemplateBinding ContentTemplate}" ContentTemplateSelector="{TemplateBinding ContentTemplateSelector}" Margin="{TemplateBinding Padding}" RecognizesAccessKey="True" HorizontalAlignment="Center" VerticalAlignment="Center" />
            <ContentPresenter x:Name="PART_HeaderHost" Grid.Row="1" Content="{TemplateBinding Header}" ContentStringFormat="{TemplateBinding HeaderStringFormat}" ContentTemplate="{TemplateBinding HeaderTemplate}" ContentTemplateSelector="{TemplateBinding HeaderTemplateSelector}" Margin="{TemplateBinding Padding}" HorizontalAlignment="Center" />
          </Grid>
          <ControlTemplate.Triggers>
            <Trigger Property="Header" Value="{x:Null}">
              <Setter TargetName="PART_HeaderHost" Property="Visibility" Value="Collapsed" />
            </Trigger>
          </ControlTemplate.Triggers>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
    <Style.Triggers>
      <DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=FontSize, Mode=OneWay, Converter={StaticResource IsGreaterThanConverter}, ConverterParameter=18}">
        <Setter Property="TextOptions.TextFormattingMode" Value="Ideal" />
      </DataTrigger>
      <Trigger Property="IsMouseOver" Value="True">
        <Setter Property="BorderBrush" Value="{StaticResource ForegroundBrush}" />
        <Setter Property="params:CommandButtons.Mask" Value="{StaticResource ForegroundBrush}" />
      </Trigger>
      <Trigger Property="IsPressed" Value="True">
        <Setter Property="BorderBrush" Value="{StaticResource MiddleLightBrush}" />
        <Setter Property="params:CommandButtons.Mask" Value="{StaticResource MiddleLightBrush}" />
      </Trigger>
      <Trigger Property="IsEnabled" Value="False">
        <Setter Property="BorderBrush" Value="{StaticResource DisabledBrush}" />
        <Setter Property="Foreground" Value="{StaticResource DisabledBrush}" />
        <Setter Property="params:CommandButtons.Mask" Value="{StaticResource DisabledBrush}" />
      </Trigger>
    </Style.Triggers>
  </Style>
  <Style x:Key="CommandButtonBaseApplicationBarStyle" TargetType="{x:Type primitives:CommandButtonBase}">
    <Setter Property="Background" Value="{StaticResource TransparentBrush}" />
    <Setter Property="BorderBrush" Value="{StaticResource ContrastBrush}" />
    <Setter Property="BorderThickness" Value="{Binding RelativeSource={RelativeSource Self}, Path=(params:General.BoldThickness), Mode=OneWay}" />
    <Setter Property="params:CommandButtons.Mask" Value="{StaticResource ContrastBrush}" />
    <Setter Property="Foreground" Value="{StaticResource ContrastBrush}" />
    <Setter Property="FontSize" Value="{Binding RelativeSource={RelativeSource Self}, Path=(params:General.ContentFontSize), Mode=OneWay}" />
    <Setter Property="FontStretch" Value="Medium" />
    <Setter Property="FontStyle" Value="Normal" />
    <Setter Property="FontWeight" Value="Normal" />
    <Setter Property="FocusVisualStyle" Value="{StaticResource FocusVisualStyle}" />
    <Setter Property="Padding" Value="{Binding RelativeSource={RelativeSource Self}, Path=(params:General.SemiBoldPadding), Mode=OneWay}" />
    <!-- Temporary removed to fix bugs 1144, 1174, 1216 -->
    <!--<Setter Property="OverridesDefaultStyle" Value="True"/>-->
    <Setter Property="SnapsToDevicePixels" Value="True" />
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type primitives:CommandButtonBase}">
          <Grid Background="{StaticResource TransparentBrush}" TextBlock.Foreground="{TemplateBinding Foreground}" TextBlock.FontFamily="{TemplateBinding FontFamily}" TextBlock.FontSize="{TemplateBinding FontSize}" TextBlock.FontStretch="{TemplateBinding FontStretch}" TextBlock.FontStyle="{TemplateBinding FontStyle}" TextBlock.FontWeight="{TemplateBinding FontWeight}" TextOptions.TextFormattingMode="{TemplateBinding TextOptions.TextFormattingMode}" TextOptions.TextRenderingMode="{TemplateBinding TextOptions.TextRenderingMode}" RenderOptions.ClearTypeHint="{TemplateBinding RenderOptions.ClearTypeHint}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">
            <Grid.RowDefinitions>
              <RowDefinition Height="*" />
              <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>
            <Ellipse x:Name="PART_Decor" Grid.Row="0" Fill="{TemplateBinding Background}" Stroke="{TemplateBinding BorderBrush}" StrokeThickness="{Binding BorderThickness, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource ThicknessToDoubleConverter}}" Stretch="Fill" HorizontalAlignment="Center" VerticalAlignment="Center" />
            <Ellipse Grid.Row="0" Fill="{TemplateBinding params:CommandButtons.Mask}" Stroke="{StaticResource TransparentBrush}" StrokeThickness="{Binding BorderThickness, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource ThicknessToDoubleConverter}}" Stretch="Fill" HorizontalAlignment="Center" VerticalAlignment="Center" Width="{Binding ElementName=PART_Decor, Path=ActualWidth, Mode=OneWay}" Height="{Binding ElementName=PART_Decor, Path=ActualHeight, Mode=OneWay}">
              <Ellipse.OpacityMask>
                <VisualBrush AutoLayoutContent="True" AlignmentX="Center" AlignmentY="Center" Stretch="None">
                  <VisualBrush.Visual>
                    <ContentPresenter x:Name="PART_ContentHost" Content="{TemplateBinding Content}" ContentStringFormat="{TemplateBinding ContentStringFormat}" ContentTemplate="{TemplateBinding ContentTemplate}" ContentTemplateSelector="{TemplateBinding ContentTemplateSelector}" Margin="{TemplateBinding Padding}" RecognizesAccessKey="True" />
                  </VisualBrush.Visual>
                </VisualBrush>
              </Ellipse.OpacityMask>
            </Ellipse>
            <ContentPresenter x:Name="PART_HeaderHost" Grid.Row="1" Content="{TemplateBinding Header}" ContentStringFormat="{TemplateBinding HeaderStringFormat}" ContentTemplate="{TemplateBinding HeaderTemplate}" ContentTemplateSelector="{TemplateBinding HeaderTemplateSelector}" Margin="{TemplateBinding Padding}" HorizontalAlignment="Center" />
          </Grid>
          <ControlTemplate.Triggers>
            <Trigger Property="Header" Value="{x:Null}">
              <Setter TargetName="PART_HeaderHost" Property="Visibility" Value="Collapsed" />
            </Trigger>
          </ControlTemplate.Triggers>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
    <Style.Triggers>
      <DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=FontSize, Mode=OneWay, Converter={StaticResource IsGreaterThanConverter}, ConverterParameter=18}">
        <Setter Property="TextOptions.TextFormattingMode" Value="Ideal" />
      </DataTrigger>
      <Trigger Property="IsMouseOver" Value="True">
        <Setter Property="Background" Value="{StaticResource SemitransparentContrastBrush}" />
        <Setter Property="BorderBrush" Value="{StaticResource ContrastBrush}" />
        <Setter Property="params:CommandButtons.Mask" Value="{StaticResource ContrastBrush}" />
      </Trigger>
      <Trigger Property="IsPressed" Value="True">
        <Setter Property="Background" Value="{StaticResource ContrastBrush}" />
        <Setter Property="BorderBrush" Value="{StaticResource ContrastBrush}" />
        <Setter Property="params:CommandButtons.Mask" Value="{StaticResource AccentBrush}" />
      </Trigger>
      <Trigger Property="IsEnabled" Value="False">
        <Setter Property="BorderBrush" Value="{StaticResource DisabledBrush}" />
        <Setter Property="Foreground" Value="{StaticResource DisabledBrush}" />
        <Setter Property="params:CommandButtons.Mask" Value="{StaticResource DisabledBrush}" />
      </Trigger>
    </Style.Triggers>
  </Style>
  <Style x:Key="{x:Type controls:CommandButton}" TargetType="{x:Type controls:CommandButton}" BasedOn="{StaticResource {x:Type primitives:CommandButtonBase}}" />
  <Style x:Key="CommandButtonApplicationBarStyle" TargetType="{x:Type controls:CommandButton}" BasedOn="{StaticResource CommandButtonBaseApplicationBarStyle}" />
  <Style x:Key="{x:Type controls:ToggleCommandButton}" TargetType="{x:Type controls:ToggleCommandButton}" BasedOn="{StaticResource {x:Type primitives:CommandButtonBase}}">
    <Style.Triggers>
      <Trigger Property="IsChecked" Value="True">
        <Setter Property="BorderBrush" Value="{StaticResource MiddleLightBrush}" />
        <Setter Property="params:CommandButtons.Mask" Value="{StaticResource MiddleLightBrush}" />
      </Trigger>
    </Style.Triggers>
  </Style>
  <Style x:Key="ToggleCommandButtonApplicationBarStyle" TargetType="{x:Type controls:ToggleCommandButton}" BasedOn="{StaticResource CommandButtonBaseApplicationBarStyle}">
    <Style.Triggers>
      <Trigger Property="IsChecked" Value="True">
        <Setter Property="Background" Value="{StaticResource ContrastBrush}" />
        <Setter Property="BorderBrush" Value="{StaticResource ContrastBrush}" />
        <Setter Property="params:CommandButtons.Mask" Value="{StaticResource AccentBrush}" />
      </Trigger>
    </Style.Triggers>
  </Style>
  <Style x:Key="DropDownCommandButtonSubmenuStyle" TargetType="{x:Type controls:Submenu}" BasedOn="{StaticResource {x:Type controls:Submenu}}">
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type controls:Submenu}">
          <Border x:Name="LayoutRoot" Tag="{DynamicResource {x:Static SystemParameters.DropShadowKey}}">
            <ScrollViewer Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Foreground="{TemplateBinding Foreground}" FontFamily="{TemplateBinding FontFamily}" FontSize="{TemplateBinding FontSize}" FontStretch="{TemplateBinding FontStretch}" FontStyle="{TemplateBinding FontStyle}" FontWeight="{TemplateBinding FontWeight}" TextOptions.TextFormattingMode="{TemplateBinding TextOptions.TextFormattingMode}" TextOptions.TextRenderingMode="{TemplateBinding TextOptions.TextRenderingMode}" RenderOptions.ClearTypeHint="{TemplateBinding RenderOptions.ClearTypeHint}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">
              <ScrollViewer.Resources>
                <Style TargetType="{x:Type ScrollBar}" BasedOn="{StaticResource {x:Type ScrollBar}}">
                  <Style.Triggers>
                    <Trigger Property="Orientation" Value="Vertical">
                      <Setter Property="BorderThickness" Value="0" />
                    </Trigger>
                  </Style.Triggers>
                </Style>
              </ScrollViewer.Resources>
              <ItemsPresenter KeyboardNavigation.DirectionalNavigation="Cycle" />
            </ScrollViewer>
          </Border>
          <ControlTemplate.Triggers>
            <DataTrigger Binding="{Binding ElementName=LayoutRoot, Path=Tag}" Value="True">
              <Setter TargetName="LayoutRoot" Property="Effect">
                <Setter.Value>
                  <DropShadowEffect Color="{Binding RelativeSource={RelativeSource AncestorType={x:Type controls:Submenu}}, Path=(params:General.ShadowBrush).(SolidColorBrush.Color)}" BlurRadius="4" ShadowDepth="0" Direction="90" Opacity="0.7" />
                </Setter.Value>
              </Setter>
              <Setter TargetName="LayoutRoot" Property="Background" Value="{StaticResource TransparentBrush}" />
              <Setter TargetName="LayoutRoot" Property="Padding" Value="4" />
            </DataTrigger>
          </ControlTemplate.Triggers>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>
  <Style x:Key="{x:Type controls:DropDownCommandButton}" TargetType="{x:Type controls:DropDownCommandButton}" BasedOn="{StaticResource {x:Type primitives:CommandButtonBase}}">
    <Style.Resources>
      <Style TargetType="{x:Type controls:Submenu}" BasedOn="{StaticResource DropDownCommandButtonSubmenuStyle}" />
    </Style.Resources>
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type controls:DropDownCommandButton}">
          <Grid Background="{StaticResource TransparentBrush}" TextBlock.Foreground="{TemplateBinding Foreground}" TextBlock.FontFamily="{TemplateBinding FontFamily}" TextBlock.FontSize="{TemplateBinding FontSize}" TextBlock.FontStretch="{TemplateBinding FontStretch}" TextBlock.FontStyle="{TemplateBinding FontStyle}" TextBlock.FontWeight="{TemplateBinding FontWeight}" TextOptions.TextFormattingMode="{TemplateBinding TextOptions.TextFormattingMode}" TextOptions.TextRenderingMode="{TemplateBinding TextOptions.TextRenderingMode}" RenderOptions.ClearTypeHint="{TemplateBinding RenderOptions.ClearTypeHint}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">
            <Grid.RowDefinitions>
              <RowDefinition Height="*" />
              <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>
            <Ellipse x:Name="PART_Decor" Grid.Row="0" Fill="{TemplateBinding Background}" Stroke="{TemplateBinding BorderBrush}" StrokeThickness="{Binding BorderThickness, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource ThicknessToDoubleConverter}}" Stretch="Fill" HorizontalAlignment="Center" VerticalAlignment="Center" />
            <ContentPresenter x:Name="PART_ContentHost" Grid.Row="0" Content="{TemplateBinding Content}" ContentStringFormat="{TemplateBinding ContentStringFormat}" ContentTemplate="{TemplateBinding ContentTemplate}" ContentTemplateSelector="{TemplateBinding ContentTemplateSelector}" Margin="{TemplateBinding Padding}" RecognizesAccessKey="True" HorizontalAlignment="Center" VerticalAlignment="Center" />
            <ContentPresenter x:Name="PART_HeaderHost" Grid.Row="1" Content="{TemplateBinding Header}" ContentStringFormat="{TemplateBinding HeaderStringFormat}" ContentTemplate="{TemplateBinding HeaderTemplate}" ContentTemplateSelector="{TemplateBinding HeaderTemplateSelector}" Margin="{TemplateBinding Padding}" HorizontalAlignment="Center" />
            <Popup x:Name="PART_Popup" Grid.Row="1" AllowsTransparency="True" IsOpen="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=IsDropDownOpen, Mode=TwoWay}" StaysOpen="False" Placement="Custom" VerticalOffset="{TemplateBinding params:General.BoldPaddingValue}" MaxHeight="{TemplateBinding MaxDropDownHeight}" />
          </Grid>
          <ControlTemplate.Triggers>
            <Trigger Property="Header" Value="{x:Null}">
              <Setter TargetName="PART_HeaderHost" Property="Visibility" Value="Collapsed" />
            </Trigger>
          </ControlTemplate.Triggers>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
    <Style.Triggers>
      <Trigger Property="IsDropDownOpen" Value="True">
        <Setter Property="BorderBrush" Value="{StaticResource MiddleLightBrush}" />
        <Setter Property="params:CommandButtons.Mask" Value="{StaticResource MiddleLightBrush}" />
      </Trigger>
    </Style.Triggers>
  </Style>
  <Style x:Key="DropDownCommandButtonApplicationBarStyle" TargetType="{x:Type controls:DropDownCommandButton}" BasedOn="{StaticResource CommandButtonBaseApplicationBarStyle}">
    <Style.Resources>
      <Style TargetType="{x:Type controls:Submenu}" BasedOn="{StaticResource DropDownCommandButtonSubmenuStyle}" />
    </Style.Resources>
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type controls:DropDownCommandButton}">
          <Grid Background="{StaticResource TransparentBrush}" TextBlock.Foreground="{TemplateBinding Foreground}" TextBlock.FontFamily="{TemplateBinding FontFamily}" TextBlock.FontSize="{TemplateBinding FontSize}" TextBlock.FontStretch="{TemplateBinding FontStretch}" TextBlock.FontStyle="{TemplateBinding FontStyle}" TextBlock.FontWeight="{TemplateBinding FontWeight}" TextOptions.TextFormattingMode="{TemplateBinding TextOptions.TextFormattingMode}" TextOptions.TextRenderingMode="{TemplateBinding TextOptions.TextRenderingMode}" RenderOptions.ClearTypeHint="{TemplateBinding RenderOptions.ClearTypeHint}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">
            <Grid.RowDefinitions>
              <RowDefinition Height="*" />
              <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>
            <Ellipse x:Name="PART_Decor" Grid.Row="0" Fill="{TemplateBinding Background}" Stroke="{TemplateBinding BorderBrush}" StrokeThickness="{Binding BorderThickness, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource ThicknessToDoubleConverter}}" Stretch="Fill" HorizontalAlignment="Center" VerticalAlignment="Center" />
            <Ellipse Grid.Row="0" Fill="{TemplateBinding params:CommandButtons.Mask}" Stroke="{StaticResource TransparentBrush}" StrokeThickness="{Binding BorderThickness, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource ThicknessToDoubleConverter}}" Stretch="Fill" HorizontalAlignment="Center" VerticalAlignment="Center" Width="{Binding ElementName=PART_Decor, Path=ActualWidth, Mode=OneWay}" Height="{Binding ElementName=PART_Decor, Path=ActualHeight, Mode=OneWay}">
              <Ellipse.OpacityMask>
                <VisualBrush AutoLayoutContent="True" AlignmentX="Center" AlignmentY="Center" Stretch="None">
                  <VisualBrush.Visual>
                    <ContentPresenter x:Name="PART_ContentHost" Content="{TemplateBinding Content}" ContentStringFormat="{TemplateBinding ContentStringFormat}" ContentTemplate="{TemplateBinding ContentTemplate}" ContentTemplateSelector="{TemplateBinding ContentTemplateSelector}" Margin="{TemplateBinding Padding}" RecognizesAccessKey="True" />
                  </VisualBrush.Visual>
                </VisualBrush>
              </Ellipse.OpacityMask>
            </Ellipse>
            <ContentPresenter x:Name="PART_HeaderHost" Grid.Row="1" Content="{TemplateBinding Header}" ContentStringFormat="{TemplateBinding HeaderStringFormat}" ContentTemplate="{TemplateBinding HeaderTemplate}" ContentTemplateSelector="{TemplateBinding HeaderTemplateSelector}" Margin="{TemplateBinding Padding}" HorizontalAlignment="Center" />
            <Popup x:Name="PART_Popup" Grid.Row="1" AllowsTransparency="True" IsOpen="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=IsDropDownOpen, Mode=TwoWay}" StaysOpen="False" Placement="Custom" VerticalOffset="{TemplateBinding params:General.BoldPaddingValue}" MaxHeight="{TemplateBinding MaxDropDownHeight}" />
          </Grid>
          <ControlTemplate.Triggers>
            <Trigger Property="Header" Value="{x:Null}">
              <Setter TargetName="PART_HeaderHost" Property="Visibility" Value="Collapsed" />
            </Trigger>
          </ControlTemplate.Triggers>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
    <Style.Triggers>
      <Trigger Property="IsDropDownOpen" Value="True">
        <Setter Property="Background" Value="{StaticResource ContrastBrush}" />
        <Setter Property="BorderBrush" Value="{StaticResource ContrastBrush}" />
        <Setter Property="params:CommandButtons.Mask" Value="{StaticResource AccentBrush}" />
      </Trigger>
    </Style.Triggers>
  </Style>
  <Style x:Key="{x:Type controls:ApplicationBar}" TargetType="{x:Type controls:ApplicationBar}">
    <Style.Resources>
      <Style TargetType="{x:Type controls:CommandButton}" BasedOn="{StaticResource CommandButtonApplicationBarStyle}" />
      <Style TargetType="{x:Type controls:ToggleCommandButton}" BasedOn="{StaticResource ToggleCommandButtonApplicationBarStyle}" />
      <Style TargetType="{x:Type controls:DropDownCommandButton}" BasedOn="{StaticResource DropDownCommandButtonApplicationBarStyle}" />
    </Style.Resources>
    <Setter Property="Background" Value="{StaticResource AccentBrush}" />
    <Setter Property="BorderBrush" Value="{StaticResource LowlightBrush}" />
    <Setter Property="BorderThickness" Value="0" />
    <Setter Property="Foreground" Value="{StaticResource ForegroundBrush}" />
    <Setter Property="FontSize" Value="{Binding RelativeSource={RelativeSource Self}, Path=(params:General.ContentFontSize), Mode=OneWay}" />
    <Setter Property="FontStretch" Value="Medium" />
    <Setter Property="FontStyle" Value="Normal" />
    <Setter Property="FontWeight" Value="Normal" />
    <Setter Property="TextOptions.TextFormattingMode" Value="Display" />
    <Setter Property="TextOptions.TextRenderingMode" Value="ClearType" />
    <Setter Property="RenderOptions.ClearTypeHint" Value="Enabled" />
    <Setter Property="HorizontalContentAlignment" Value="Stretch" />
    <Setter Property="VerticalContentAlignment" Value="Stretch" />
    <Setter Property="Padding" Value="{Binding RelativeSource={RelativeSource Self}, Path=(params:General.BoldPadding), Mode=OneWay}" />
    <Setter Property="SnapsToDevicePixels" Value="True" />
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type controls:ApplicationBar}">
          <Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" TextBlock.Foreground="{TemplateBinding Foreground}" TextBlock.FontFamily="{TemplateBinding FontFamily}" TextBlock.FontSize="{TemplateBinding FontSize}" TextBlock.FontStretch="{TemplateBinding FontStretch}" TextBlock.FontStyle="{TemplateBinding FontStyle}" TextBlock.FontWeight="{TemplateBinding FontWeight}" TextOptions.TextFormattingMode="{TemplateBinding TextOptions.TextFormattingMode}" TextOptions.TextRenderingMode="{TemplateBinding TextOptions.TextRenderingMode}" RenderOptions.ClearTypeHint="{TemplateBinding RenderOptions.ClearTypeHint}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">
            <ItemsPresenter />
          </Border>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
    <Style.Triggers>
      <DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=FontSize, Mode=OneWay, Converter={StaticResource IsGreaterThanConverter}, ConverterParameter=18}">
        <Setter Property="TextOptions.TextFormattingMode" Value="Ideal" />
      </DataTrigger>
    </Style.Triggers>
  </Style>
  <Style TargetType="{x:Type ToolTip}">
    <Setter Property="Background" Value="{StaticResource BackgroundBrush}" />
    <Setter Property="BorderBrush" Value="{StaticResource MiddleLightBrush}" />
    <Setter Property="BorderThickness" Value="{Binding RelativeSource={RelativeSource Self}, Path=(params:General.DefaultThickness), Mode=OneWay}" />
    <Setter Property="Foreground" Value="{StaticResource ForegroundBrush}" />
    <Setter Property="FontSize" Value="{Binding RelativeSource={RelativeSource Self}, Path=(params:General.TextFontSize), Mode=OneWay}" />
    <Setter Property="FontStretch" Value="Medium" />
    <Setter Property="FontStyle" Value="Normal" />
    <Setter Property="FontWeight" Value="Normal" />
    <Setter Property="TextOptions.TextFormattingMode" Value="Display" />
    <Setter Property="TextOptions.TextRenderingMode" Value="ClearType" />
    <Setter Property="RenderOptions.ClearTypeHint" Value="Enabled" />
    <Setter Property="HasDropShadow" Value="{DynamicResource {x:Static SystemParameters.DropShadowKey}}" />
    <Setter Property="params:General.ShadowBrush" Value="{StaticResource ForegroundBrush}" />
    <Setter Property="Focusable" Value="False" />
    <Setter Property="FocusVisualStyle" Value="{x:Null}" />
    <Setter Property="HorizontalContentAlignment" Value="Left" />
    <Setter Property="VerticalContentAlignment" Value="Center" />
    <Setter Property="Padding" Value="{Binding RelativeSource={RelativeSource Self}, Path=(params:General.BoldPadding), Mode=OneWay}" />
    <!-- Temporary removed to fix bugs 1144, 1174, 1216 -->
    <!--<Setter Property="OverridesDefaultStyle" Value="True"/>-->
    <Setter Property="SnapsToDevicePixels" Value="True" />
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type ToolTip}">
          <Border x:Name="LayoutRoot">
            <Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" TextBlock.Foreground="{TemplateBinding Foreground}" TextBlock.FontFamily="{TemplateBinding FontFamily}" TextBlock.FontSize="{TemplateBinding FontSize}" TextBlock.FontStretch="{TemplateBinding FontStretch}" TextBlock.FontStyle="{TemplateBinding FontStyle}" TextBlock.FontWeight="{TemplateBinding FontWeight}" TextOptions.TextFormattingMode="{TemplateBinding TextOptions.TextFormattingMode}" TextOptions.TextRenderingMode="{TemplateBinding TextOptions.TextRenderingMode}" RenderOptions.ClearTypeHint="{TemplateBinding RenderOptions.ClearTypeHint}" Padding="{TemplateBinding Padding}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">
              <ContentPresenter HorizontalAlignment="{TemplateBinding Control.HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding Control.VerticalContentAlignment}" SnapsToDevicePixels="{TemplateBinding UIElement.SnapsToDevicePixels}" />
            </Border>
          </Border>
          <ControlTemplate.Triggers>
            <Trigger Property="HasDropShadow" Value="True">
              <Setter TargetName="LayoutRoot" Property="Effect">
                <Setter.Value>
                  <DropShadowEffect Color="{Binding RelativeSource={RelativeSource AncestorType={x:Type ToolTip}}, Path=(params:General.ShadowBrush).(SolidColorBrush.Color)}" BlurRadius="5" ShadowDepth="2" Direction="315" Opacity="0.1" />
                </Setter.Value>
              </Setter>
              <Setter TargetName="LayoutRoot" Property="Background" Value="{StaticResource TransparentBrush}" />
              <Setter TargetName="LayoutRoot" Property="Padding" Value="0,0,6,6" />
            </Trigger>
          </ControlTemplate.Triggers>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
    <Style.Triggers>
      <DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=FontSize, Mode=OneWay, Converter={StaticResource IsGreaterThanConverter}, ConverterParameter=18}">
        <Setter Property="TextOptions.TextFormattingMode" Value="Ideal" />
      </DataTrigger>
    </Style.Triggers>
  </Style>
  <Style x:Key="{x:Static controls:Window.DefaultCaptionButtonStyleKey}" TargetType="{x:Type Button}" BasedOn="{StaticResource {x:Type Button}}">
    <Setter Property="Background" Value="{DynamicResource TransparentBrush}" />
    <Setter Property="BorderBrush" Value="{DynamicResource TransparentBrush}" />
    <Setter Property="Foreground" Value="{DynamicResource ForegroundBrush}" />
    <Setter Property="FocusVisualStyle" Value="{x:Null}" />
    <Setter Property="IsTabStop" Value="False" />
    <Setter Property="MinWidth" Value="32" />
    <Setter Property="MinHeight" Value="32" />
    <Setter Property="ToolTipService.ShowOnDisabled" Value="True" />
    <Style.Triggers>
      <Trigger Property="IsMouseOver" Value="True">
        <Setter Property="Background" Value="{DynamicResource HighlightBrush}" />
        <Setter Property="BorderBrush" Value="{DynamicResource HighlightBrush}" />
        <Setter Property="Foreground" Value="{DynamicResource ForegroundBrush}" />
      </Trigger>
      <Trigger Property="IsPressed" Value="True">
        <Setter Property="Background" Value="{DynamicResource AccentBrush}" />
        <Setter Property="BorderBrush" Value="{DynamicResource AccentBrush}" />
        <Setter Property="Foreground" Value="{DynamicResource ContrastBrush}" />
      </Trigger>
    </Style.Triggers>
  </Style>
  <Style x:Key="{x:Static controls:Window.MainWindowCaptionButtonStyleKey}" TargetType="{x:Type Button}" BasedOn="{StaticResource {x:Type Button}}">
    <Setter Property="Background" Value="{DynamicResource AccentBrush}" />
    <Setter Property="BorderBrush" Value="{DynamicResource AccentBrush}" />
    <Setter Property="Foreground" Value="{DynamicResource ContrastBrush}" />
    <Setter Property="FocusVisualStyle" Value="{x:Null}" />
    <Setter Property="IsTabStop" Value="False" />
    <Setter Property="MinWidth" Value="32" />
    <Setter Property="MinHeight" Value="32" />
    <Setter Property="ToolTipService.ShowOnDisabled" Value="True" />
    <Style.Triggers>
      <Trigger Property="IsMouseOver" Value="True">
        <Setter Property="Background" Value="{DynamicResource SemitransparentContrastBrush}" />
        <Setter Property="BorderBrush" Value="{DynamicResource SemitransparentContrastBrush}" />
        <Setter Property="Foreground" Value="{DynamicResource ContrastBrush}" />
      </Trigger>
      <Trigger Property="IsPressed" Value="True">
        <Setter Property="Background" Value="{DynamicResource ContrastBrush}" />
        <Setter Property="BorderBrush" Value="{DynamicResource ContrastBrush}" />
        <Setter Property="Foreground" Value="{DynamicResource AccentBrush}" />
      </Trigger>
    </Style.Triggers>
  </Style>
  <Style x:Key="{x:Type controls:Window}" TargetType="{x:Type controls:Window}">
    <Setter Property="Background" Value="{DynamicResource BackgroundBrush}" />
    <Setter Property="BorderBrush" Value="{DynamicResource AccentBrush}" />
    <Setter Property="BorderThickness" Value="0" />
    <Setter Property="Foreground" Value="{DynamicResource ForegroundBrush}" />
    <Setter Property="FontFamily" Value="Segoe UI" />
    <Setter Property="FontSize" Value="{Binding RelativeSource={RelativeSource Self}, Path=(params:General.TextFontSize), Mode=OneWay}" />
    <Setter Property="FontStretch" Value="Medium" />
    <Setter Property="FontStyle" Value="Normal" />
    <Setter Property="FontWeight" Value="Normal" />
    <Setter Property="TextOptions.TextFormattingMode" Value="Display" />
    <Setter Property="TextOptions.TextRenderingMode" Value="ClearType" />
    <Setter Property="RenderOptions.ClearTypeHint" Value="Enabled" />
    <Setter Property="HasDropShadow" Value="{DynamicResource {x:Static SystemParameters.DropShadowKey}}" />
    <Setter Property="FocusVisualStyle" Value="{x:Null}" />
    <Setter Property="Focusable" Value="True" />
    <Setter Property="ResizeMode" Value="CanResizeWithGrip" />
    <Setter Property="HorizontalContentAlignment" Value="Stretch" />
    <Setter Property="VerticalContentAlignment" Value="Stretch" />
    <Setter Property="Padding" Value="0" />
    <Setter Property="SnapsToDevicePixels" Value="True" />
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type controls:Window}">
          <Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" UseLayoutRounding="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">
            <Grid x:Name="PART_LayoutRoot">
              <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="*" />
              </Grid.RowDefinitions>
              <Grid x:Name="PART_Caption" Grid.Row="0">
                <Grid.ColumnDefinitions>
                  <ColumnDefinition Width="Auto" />
                  <ColumnDefinition Width="*" />
                  <ColumnDefinition Width="Auto" />
                  <ColumnDefinition Width="Auto" />
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                  <RowDefinition Height="Auto" />
                  <RowDefinition Height="Auto" />
                </Grid.RowDefinitions>
                <Image x:Name="PART_Icon" Grid.Column="0" Grid.Row="0" Grid.RowSpan="2" Source="{TemplateBinding Icon}" />
                <TextBlock x:Name="PART_Title" Grid.Column="1" Grid.Row="0" Grid.RowSpan="2" Text="{TemplateBinding Title}" FontSize="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(params:General.TitleFontSize), Mode=OneWay}" FontWeight="Normal" TextTrimming="CharacterEllipsis" Margin="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(params:General.BoldPadding), Mode=OneWay}" VerticalAlignment="Center" />
                <Decorator Grid.Column="2" Grid.Row="0" Grid.RowSpan="2" controls:Window.IsTitleBarHost="True" WindowChrome.IsHitTestVisibleInChrome="True" />
                <Grid Grid.Column="3" Grid.Row="0" Grid.RowSpan="2" WindowChrome.IsHitTestVisibleInChrome="True">
                  <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="Auto" />
                  </Grid.ColumnDefinitions>
                  <Button x:Name="PART_Minimize" Grid.Column="0" BorderThickness="0" Command="{x:Static controls:WindowCommands.Minimize}" ToolTip="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(params:Window.MinimizeButtonToolTip), Mode=OneWay}" Style="{DynamicResource {x:Static controls:Window.DefaultCaptionButtonStyleKey}}">
                    <Path Data="{StaticResource MinimizeIcon}" Fill="{Binding RelativeSource={RelativeSource AncestorType={x:Type Button}}, Path=Foreground, Mode=OneWay}" Stretch="None" RenderOptions.EdgeMode="Aliased" Width="10" Height="10" />
                  </Button>
                  <Button x:Name="PART_Maximize" Grid.Column="1" BorderThickness="0" Command="{x:Static controls:WindowCommands.Maximize}" ToolTip="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(params:Window.MaximizeButtonToolTip), Mode=OneWay}" Style="{DynamicResource {x:Static controls:Window.DefaultCaptionButtonStyleKey}}">
                    <Path Data="{StaticResource MaximizeIcon}" Stroke="{Binding RelativeSource={RelativeSource AncestorType={x:Type Button}}, Path=Foreground, Mode=OneWay}" Stretch="None" RenderOptions.EdgeMode="Aliased" Width="10" Height="10" />
                  </Button>
                  <Button x:Name="PART_Restore" Grid.Column="1" BorderThickness="0" Command="{x:Static controls:WindowCommands.Restore}" ToolTip="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(params:Window.RestoreButtonToolTip), Mode=OneWay}" Style="{DynamicResource {x:Static controls:Window.DefaultCaptionButtonStyleKey}}" Visibility="Hidden">
                    <Path Data="{StaticResource RestoreIcon}" Stroke="{Binding RelativeSource={RelativeSource AncestorType={x:Type Button}}, Path=Foreground, Mode=OneWay}" Stretch="None" RenderOptions.EdgeMode="Aliased" Width="10" Height="10" />
                  </Button>
                  <Button x:Name="PART_Close" Grid.Column="2" BorderThickness="0" Command="{x:Static controls:WindowCommands.Close}" ToolTip="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(params:Window.CloseButtonToolTip), Mode=OneWay}" Style="{DynamicResource {x:Static controls:Window.DefaultCaptionButtonStyleKey}}">
                    <Path Data="{StaticResource CloseIcon}" Stroke="{Binding RelativeSource={RelativeSource AncestorType={x:Type Button}}, Path=Foreground, Mode=OneWay}" Stretch="None" RenderOptions.EdgeMode="Aliased" Width="10" Height="10" />
                  </Button>
                </Grid>
                <controls:ProgressBar x:Name="PART_ProgressBar" Grid.Column="0" Grid.ColumnSpan="4" Grid.Row="0" Background="{DynamicResource TransparentBrush}" Value="{TemplateBinding Progress}" VerticalAlignment="Top" Height="{Binding RelativeSource={RelativeSource Self}, Path=(params:General.BoldThicknessValue), Mode=OneWay}" />
              </Grid>
              <AdornerDecorator Grid.Row="1" TextOptions.TextFormattingMode="{TemplateBinding TextOptions.TextFormattingMode}" TextOptions.TextRenderingMode="{TemplateBinding TextOptions.TextRenderingMode}" RenderOptions.ClearTypeHint="{TemplateBinding RenderOptions.ClearTypeHint}">
                <ContentPresenter Margin="{TemplateBinding Padding}" />
              </AdornerDecorator>
              <Decorator Grid.Row="1" controls:Window.IsApplicationBarHost="True" />
              <ResizeGrip x:Name="PART_Grip" Grid.Row="1" WindowChrome.ResizeGripDirection="BottomRight" IsTabStop="False" Visibility="Collapsed" HorizontalAlignment="Right" VerticalAlignment="Bottom" />
            </Grid>
          </Border>
          <ControlTemplate.Triggers>
            <DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=(params:General.TitleFontSize), Mode=OneWay, Converter={StaticResource IsGreaterThanConverter}, ConverterParameter=18}">
              <Setter TargetName="PART_Title" Property="TextOptions.TextFormattingMode" Value="Ideal" />
            </DataTrigger>
            <Trigger Property="IsBusy" Value="True">
              <Setter TargetName="PART_ProgressBar" Property="State" Value="Indeterminate" />
            </Trigger>
            <Trigger Property="controls:Window.IsMainWindow" Value="True">
              <Setter TargetName="PART_Caption" Property="Background" Value="{DynamicResource AccentBrush}" />
              <Setter TargetName="PART_ProgressBar" Property="Foreground" Value="{DynamicResource ContrastBrush}" />
              <Setter TargetName="PART_Title" Property="Foreground" Value="{DynamicResource ContrastBrush}" />
              <Setter TargetName="PART_Minimize" Property="Style" Value="{StaticResource {x:Static controls:Window.MainWindowCaptionButtonStyleKey}}" />
              <Setter TargetName="PART_Maximize" Property="Style" Value="{StaticResource {x:Static controls:Window.MainWindowCaptionButtonStyleKey}}" />
              <Setter TargetName="PART_Restore" Property="Style" Value="{StaticResource {x:Static controls:Window.MainWindowCaptionButtonStyleKey}}" />
              <Setter TargetName="PART_Close" Property="Style" Value="{StaticResource {x:Static controls:Window.MainWindowCaptionButtonStyleKey}}" />
            </Trigger>
            <Trigger Property="WindowState" Value="Maximized">
              <Setter TargetName="PART_Maximize" Property="Visibility" Value="Hidden" />
              <Setter TargetName="PART_Restore" Property="Visibility" Value="Visible" />
            </Trigger>
            <Trigger Property="WindowStyle" Value="None">
              <Trigger.Setters>
                <Setter TargetName="PART_Title" Property="Visibility" Value="Collapsed" />
                <Setter TargetName="PART_Minimize" Property="Visibility" Value="Collapsed" />
                <Setter TargetName="PART_Maximize" Property="Visibility" Value="Collapsed" />
                <Setter TargetName="PART_Restore" Property="Visibility" Value="Collapsed" />
                <Setter TargetName="PART_Close" Property="Visibility" Value="Collapsed" />
              </Trigger.Setters>
            </Trigger>
            <Trigger Property="WindowStyle" Value="ToolWindow">
              <Trigger.Setters>
                <Setter TargetName="PART_Minimize" Property="Visibility" Value="Collapsed" />
                <Setter TargetName="PART_Maximize" Property="Visibility" Value="Collapsed" />
                <Setter TargetName="PART_Restore" Property="Visibility" Value="Collapsed" />
              </Trigger.Setters>
            </Trigger>
            <Trigger Property="ResizeMode" Value="NoResize">
              <Trigger.Setters>
                <Setter TargetName="PART_Minimize" Property="Visibility" Value="Collapsed" />
                <Setter TargetName="PART_Maximize" Property="Visibility" Value="Collapsed" />
                <Setter TargetName="PART_Restore" Property="Visibility" Value="Collapsed" />
              </Trigger.Setters>
            </Trigger>
            <Trigger Property="ResizeMode" Value="CanMinimize">
              <Trigger.Setters>
                <Setter TargetName="PART_Maximize" Property="Visibility" Value="Collapsed" />
                <Setter TargetName="PART_Restore" Property="Visibility" Value="Collapsed" />
              </Trigger.Setters>
            </Trigger>
            <Trigger Property="ResizeMode" Value="CanResizeWithGrip">
              <Trigger.Setters>
                <Setter TargetName="PART_Grip" Property="Visibility" Value="Visible" />
              </Trigger.Setters>
            </Trigger>
          </ControlTemplate.Triggers>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
    <Style.Triggers>
      <DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=FontSize, Mode=OneWay, Converter={StaticResource IsGreaterThanConverter}, ConverterParameter=18}">
        <Setter Property="TextOptions.TextFormattingMode" Value="Ideal" />
      </DataTrigger>
      <Trigger Property="HasDropShadow" Value="False">
        <Setter Property="BorderThickness" Value="{Binding RelativeSource={RelativeSource Self}, Path=(params:General.DefaultThickness), Mode=OneWay}" />
      </Trigger>
      <Trigger Property="WindowStyle" Value="{x:Static WindowStyle.None}">
        <Setter Property="ResizeMode" Value="NoResize" />
      </Trigger>
      <Trigger Property="WindowStyle" Value="{x:Static WindowStyle.ToolWindow}">
        <Setter Property="ResizeMode" Value="NoResize" />
      </Trigger>
    </Style.Triggers>
  </Style>
</ResourceDictionary>